... | ... |
@@ -14,29 +14,29 @@ |
14 | 14 |
|
15 | 15 |
my $op = param('op') || ''; |
16 | 16 |
my $errors; |
17 |
- if ($op eq 'pull' && lc $self->req->method eq 'post') { |
|
17 |
+ if ($op eq 'import' && lc $self->req->method eq 'post') { |
|
18 | 18 |
|
19 | 19 |
# Validation |
20 | 20 |
my $api = gitprep_api; |
21 | 21 |
my $params = $api->params; |
22 | 22 |
my $rule = [ |
23 | 23 |
user => [ |
24 |
- 'user_name' |
|
24 |
+ ['user_name' => 'User name is invalid.'] |
|
25 | 25 |
], |
26 | 26 |
project => [ |
27 |
- 'project_name' |
|
27 |
+ ['project_name' => 'Repository name is invalid.'] |
|
28 | 28 |
], |
29 | 29 |
branch => [ |
30 |
- 'any' |
|
30 |
+ ['not_blank' => 'Branch name is empty.'] |
|
31 | 31 |
], |
32 | 32 |
remote_user => [ |
33 |
- 'user_name' |
|
33 |
+ ['user_name' => 'Remote User name is invalid.'] |
|
34 | 34 |
], |
35 | 35 |
remote_project => [ |
36 |
- 'project_name' |
|
36 |
+ ['project_name' => 'Remote repository is invalid.'] |
|
37 | 37 |
], |
38 | 38 |
remote_branch => [ |
39 |
- 'any' |
|
39 |
+ ['not_blank' => 'Remote branch name is empty.'] |
|
40 | 40 |
] |
41 | 41 |
]; |
42 | 42 |
my $vresult = app->validator->validate($params, $rule); |
... | ... |
@@ -51,24 +51,35 @@ |
51 | 51 |
my $remote_project = $safe_params->{remote_project}; |
52 | 52 |
my $remote_branch = $safe_params->{remote_branch}; |
53 | 53 |
|
54 |
- $git->import_branch( |
|
55 |
- $user, |
|
56 |
- $project, |
|
57 |
- $branch, |
|
58 |
- $remote_user, |
|
59 |
- $remote_project, |
|
60 |
- $remote_branch |
|
61 |
- ); |
|
54 |
+ eval { |
|
55 |
+ $git->import_branch( |
|
56 |
+ $user, |
|
57 |
+ $project, |
|
58 |
+ $branch, |
|
59 |
+ $remote_user, |
|
60 |
+ $remote_project, |
|
61 |
+ $remote_branch |
|
62 |
+ ); |
|
63 |
+ }; |
|
64 |
+ |
|
65 |
+ if ($@) { |
|
66 |
+ $errors = ['Internal Error']; |
|
67 |
+ } |
|
68 |
+ else { |
|
69 |
+ flash(message => "Success: import \"$remote_user / $remote_project / $remote_branch\" into \"$user / $project / $branch\""); |
|
70 |
+ $self->redirect_to('current'); |
|
71 |
+ return; |
|
72 |
+ } |
|
62 | 73 |
} |
63 | 74 |
else { |
64 |
- $errors = ['Parameter is invalid']; |
|
75 |
+ $errors = $vresult->messages; |
|
65 | 76 |
} |
66 | 77 |
} |
67 | 78 |
%> |
68 | 79 |
|
69 | 80 |
% layout 'common', title => "Import branch"; |
70 | 81 |
%= include 'include/header'; |
71 |
- |
|
82 |
+ |
|
72 | 83 |
%= javascript begin |
73 | 84 |
$('document').ready(function () { |
74 | 85 |
|
... | ... |
@@ -81,6 +92,13 @@ |
81 | 92 |
% end |
82 | 93 |
|
83 | 94 |
<div class="container"> |
95 |
+ %= include '/include/project_header'; |
|
96 |
+ % if (my $message = flash('message')) { |
|
97 |
+ <div class="alert alert-success"> |
|
98 |
+ <button type="button" class="close" data-dismiss="alert">×</button> |
|
99 |
+ <%= $message %> |
|
100 |
+ </div> |
|
101 |
+ % } |
|
84 | 102 |
% if ($errors) { |
85 | 103 |
<div class="alert alert-error"> |
86 | 104 |
<button type="button" class="close" data-dismiss="alert">×</button> |
... | ... |
@@ -92,19 +110,21 @@ |
92 | 110 |
<h3>Import branch</h3> |
93 | 111 |
<form action="<%= url_for->query(op => 'import') %>" method="post"> |
94 | 112 |
<div class="row" style="font-size:22px"> |
95 |
- <div class="span5"> |
|
113 |
+ <div class="span6"> |
|
96 | 114 |
<div class="well" style="text-align:center"> |
97 | 115 |
<div style="color:blue;margin-bottom:15px"> |
98 | 116 |
%= "$user / $project"; |
99 | 117 |
</div> |
100 | 118 |
<div> |
101 |
- %= text_field 'branch'; |
|
119 |
+ %= text_field 'branch', placeholder => "Branch name", style => "margin-top:12px;width:250px"; |
|
120 |
+ <button name="copy-branch-name", class="btn" style="font-size:12px; padding-left:3px;padding-right:3px;color:#666">Copy Branch Name</button> |
|
121 |
+ </div> |
|
122 |
+ <div> |
|
123 |
+ %= submit_button 'Import', style => "width:100px;margin-top:10px;", class => "btn"; |
|
102 | 124 |
</div> |
103 |
- <button name="copy-branch-name", class="btn">Copy Branch Name</button> |
|
104 |
- %= submit_button 'Import', style => "width:100px", class => "btn"; |
|
105 | 125 |
</div> |
106 | 126 |
</div> |
107 |
- <div class="span2"> |
|
127 |
+ <div class="span1"> |
|
108 | 128 |
<div style="padding: 19px;text-align:center;font-size:26px"> |
109 | 129 |
⇐ |
110 | 130 |
</div> |
... | ... |
@@ -115,7 +135,7 @@ |
115 | 135 |
%= "$remote_user / $remote_project"; |
116 | 136 |
</div> |
117 | 137 |
% param(remote_branch => $remote_branch); |
118 |
- %= select_field 'remote_branch' => $remote_branch_names; |
|
138 |
+ %= select_field 'remote_branch' => $remote_branch_names, style => "width:250px"; |
|
119 | 139 |
</div> |
120 | 140 |
</div> |
121 | 141 |
</div> |
... | ... |
@@ -51,8 +51,9 @@ |
51 | 51 |
% end |
52 | 52 |
|
53 | 53 |
%= include '/include/header'; |
54 |
- |
|
54 |
+ |
|
55 | 55 |
<div class="container" style="min-heigth:500px"> |
56 |
+ %= include '/include/project_header'; |
|
56 | 57 |
<h3>Members of the <%= $project %> Network</h3> |
57 | 58 |
<div class="well" style="padding:5px 10px 0 10px;margin-bottom:20px"> |
58 | 59 |
<span class="label label-info">My branch</span> |
... | ... |
@@ -58,6 +58,7 @@ |
58 | 58 |
% end |
59 | 59 |
|
60 | 60 |
<div class="container"> |
61 |
+ %= include '/include/project_header'; |
|
61 | 62 |
<h3>Graph</h3> |
62 | 63 |
<div style="margin-bottom:20px">Compare 100 commits.</div> |
63 | 64 |
<div style="margin-bottom:10px"> |