added Tags link
|
1 |
<% |
2 |
# API |
|
cleanup
|
3 |
my $api = gitprep_api; |
added Tags link
|
4 | |
cleanup branches page
|
5 |
# Parameters |
improve branches page open c...
|
6 |
my $user_id = param('user'); |
7 |
my $project_id = param('project'); |
|
improved branches page desig...
|
8 |
my $op = param('op') || ''; |
improve tags page design
|
9 |
my $page = param('page') || 1; |
added Tags link
|
10 |
|
11 |
# Git |
|
revert encoding support
|
12 |
my $git = $self->app->git; |
added branch deleting featur...
|
13 | |
14 |
# Delete |
|
15 |
my $errors; |
|
fix branch not deleted bug a...
|
16 |
if ($op eq 'delete' && lc $self->req->method eq 'post') { |
17 |
|
|
18 |
# Forbbiden |
|
improve branches page open c...
|
19 |
unless ($api->logined($user_id)) { |
fix branch not deleted bug a...
|
20 |
$self->redirect_to('/'); |
21 |
return; |
|
22 |
} |
|
cleanup branch page validati...
|
23 |
|
24 |
# Parameters |
|
25 |
my $branch = param('branch'); |
|
26 |
|
|
27 |
# Validator |
|
28 |
my $vc = app->vc; |
|
29 |
|
|
30 |
# Validation result |
|
31 |
my $validation = $vc->validation; |
|
32 |
|
|
33 |
# "branch" |
|
34 |
if (!(defined $branch && length $branch)) { |
|
35 |
$validation->add_failed(branch => 'Branch name is empty'); |
|
36 |
} |
|
added branch deleting featur...
|
37 | |
cleanup branch page validati...
|
38 |
if ($validation->is_valid) { |
added branch deleting featur...
|
39 |
# Delete branch |
improve branches page open c...
|
40 |
eval { $git->delete_branch(app->rep_info($user_id, $project_id), $branch) }; |
improve error message
|
41 |
if (my $e = $@) { |
42 |
app->log->error(url_with . ": $e"); |
|
fix branch not deleted bug a...
|
43 |
$errors = ['Internal Error']; |
added branch deleting featur...
|
44 |
} |
45 |
else { |
|
fix branch not deleted bug a...
|
46 |
$self->flash(message => "Branch $branch is deleted."); |
47 |
$self->redirect_to; |
|
added branch deleting featur...
|
48 |
return; |
49 |
} |
|
50 |
} |
|
cleanup branch page validati...
|
51 |
else { $errors = $validation->messages } |
added branch deleting featur...
|
52 |
} |
fix branch not deleted bug a...
|
53 |
|
54 |
# Default branch |
|
improve branches page open c...
|
55 |
my $default_branch_name = app->manager->default_branch($user_id, $project_id); |
56 |
my $default_branch = $git->branch($self->app->rep_info($user_id, $project_id), $default_branch_name); |
|
improve some branches page
|
57 |
|
58 |
# Branches |
|
simplify branches
|
59 |
my $branches = []; |
improve tags page design
|
60 | |
61 |
# Pagenation |
|
62 |
my $page_count = 20; |
|
63 |
my $skip = $page_count * ($page - 1); |
|
fix branch not deleted bug a...
|
64 |
|
fix branch paging
|
65 |
my $all_branches = $git->branches($self->app->rep_info($user_id, $project_id)); |
fix branch not deleted bug a...
|
66 |
my $max = 0; |
improve tags page design
|
67 |
my $all_count = 0; |
fix branch paging
|
68 |
for my $branch (@$all_branches) { |
cleanup branch_status
|
69 |
$branch->{status} = $git->branch_status( |
improve branches page open c...
|
70 |
$self->app->rep_info($user_id, $project_id), |
cleanup rep_info
|
71 |
$default_branch->{name}, |
72 |
$branch->{name} |
|
cleanup branch_status
|
73 |
); |
fix branch not deleted bug a...
|
74 |
$max = $branch->{status}{ahead} if $max < $branch->{status}{ahead}; |
75 |
$max = $branch->{status}{behind} if $max < $branch->{status}{behind}; |
|
improve some branches page
|
76 |
|
fix branches bar
|
77 |
if ($branch->{status}{ahead} > 100) { |
78 |
$branch->{status}{ahead_bar} = 100; |
|
79 |
} |
|
80 |
else { |
|
81 |
$branch->{status}{ahead_bar} = $branch->{status}{ahead}; |
|
82 |
} |
|
83 |
if ($branch->{status}{behind} > 100) { |
|
84 |
$branch->{status}{behind_bar} = 100; |
|
85 |
} |
|
86 |
else { |
|
87 |
$branch->{status}{behind_bar} = $branch->{status}{behind}; |
|
88 |
} |
|
89 |
|
|
90 |
$max = 100 if $max > 100; |
|
91 |
|
|
simplify branches
|
92 |
if ($all_count >= $skip && $all_count < $skip + $page_count) { |
93 |
push @$branches, $branch; |
|
improve some branches page
|
94 |
} |
simplify branches
|
95 |
$all_count++; |
added branch deleting featur...
|
96 |
} |
improve tags page design
|
97 |
|
fix branches page pull reque...
|
98 |
my $original_project_row_id = app->dbi->model('project')->select( |
99 |
'original_project', |
|
remove table __ prefix
|
100 |
where => {'user.id' => $user_id, 'project.id' => $project_id} |
fix branches page pull reque...
|
101 |
)->value; |
102 |
|
|
103 |
my $original_project; |
|
104 |
if ($original_project_row_id) { |
|
105 |
$original_project = app->dbi->model('project')->select( |
|
106 |
[ |
|
107 |
{__MY__ => '*'}, |
|
remove table __ prefix
|
108 |
{user => ['id']} |
fix branches page pull reque...
|
109 |
], |
110 |
where => {'project.row_id' => $original_project_row_id} |
|
111 |
)->one; |
|
112 |
} |
|
added Tags link
|
113 |
%> |
114 | ||
improve branches page open c...
|
115 |
% layout 'common', title => "branches \x{30fb} $user_id/$project_id"; |
added merged branches to bra...
|
116 | |
cleanup
|
117 |
%= include '/include/header'; |
cleanup
|
118 |
|
added branch deleting featur...
|
119 |
<div class="container" style="padding-bottom:30px"> |
fix branch not deleted bug a...
|
120 |
%= include '/include/errors', errors => $errors; |
121 |
%= include '/include/message', message => flash('message'); |
|
added branch deleting featur...
|
122 |
|
improve some branches page
|
123 |
<!-- Branches (for tests) --> |
design branches page
|
124 |
|
simplify branches
|
125 |
<h1 class="topic1">Branches</h1> |
126 |
% if (@$branches) { |
|
improve branch design
|
127 |
<ul class="branches"> |
improve branches design
|
128 |
% if (@$branches) { |
improve tags page design
|
129 |
% my $branches_count; |
improve branches design
|
130 |
% for (my $i = 0; $i < @$branches; $i++) { |
imrpove branches page
|
131 |
<% |
132 |
my $branch = $branches->[$i]; |
|
improve branches page open c...
|
133 |
my $branch_name = $branch->{name}; |
add user page link from user...
|
134 | |
cleanup
|
135 |
my $commit_author_email = $branch->{commit}{author_email}; |
add user page link from user...
|
136 |
my $commit_author_id = app->dbi->model('user')->select( |
137 |
'id', |
|
fix mail bug
|
138 |
where => {email => $commit_author_email} |
add user page link from user...
|
139 |
)->value; |
improve branches page open c...
|
140 | |
141 |
my $pull_request = app->dbi->model('pull_request')->select( |
|
fix branches page bug
|
142 |
{__MY__ => ['row_id']}, |
improve branches page open c...
|
143 |
where => { |
remove table __ prefix
|
144 |
'base_project.id' => $project_id, |
145 |
'base_project__user.id' => $user_id, |
|
fix pull_request table bug
|
146 |
base_branch => $default_branch_name, |
147 |
target_branch => $branch_name |
|
improve branches page open c...
|
148 |
} |
149 |
)->one; |
|
fix branches page
|
150 |
|
151 |
my $issue; |
|
152 |
if ($pull_request) { |
|
153 |
$issue = app->dbi->model('issue')->select( |
|
154 |
where => {pull_request => $pull_request->{row_id}} |
|
155 |
)->one; |
|
156 |
} |
|
157 |
|
|
imrpove branches page
|
158 |
%> |
159 | ||
simplify branches
|
160 |
<li> |
161 |
<ul> |
|
162 |
<li> |
|
163 |
<div class="branches-name"> |
|
164 |
<a href="<%= url_for("/$user_id/$project_id/tree/$branch_name") %>"> |
|
165 |
<%= $branch_name %> |
|
166 |
</a> |
|
167 |
</div> |
|
168 |
<div class="branches-age" title="<%= $branch->{commit}{age_string_datetime_local} %>"> |
|
169 |
Updated <%= $branch->{commit}{age_string} %> by |
|
170 |
</div> |
|
171 |
<div class="branches-author" title="<%= $branch->{commit}{author_email} %>"> |
|
172 |
% if (defined $commit_author_id) { |
|
173 |
<a href="<%= url_for("/$commit_author_id") %>"><%= $commit_author_id %></a> |
|
imrpove branches page
|
174 |
% } else { |
simplify branches
|
175 |
<%= $branch->{commit}{author_name} %> |
improve branches design
|
176 |
% } |
simplify branches
|
177 |
</div> |
178 |
</li> |
|
179 |
<li class="second-child"> |
|
180 |
% if ($branch_name eq $default_branch_name) { |
|
181 |
<div style="padding-left:80px;padding-top:3px"> |
|
182 |
<div class="branches-default"> |
|
183 |
Default |
|
184 |
</div> |
|
185 |
</div> |
|
186 |
% } else { |
|
187 |
<table class="ahead-behind"> |
|
188 |
<tr> |
|
189 |
<td class="ahead-behind-behind-count"> |
|
190 |
<%= $branch->{status}{behind} %> |
|
191 |
</td> |
|
192 |
<td class="ahead-behind-separate"> |
|
193 |
</td> |
|
194 |
<td style="padding-left:3px"> |
|
195 |
<%= $branch->{status}{ahead} %> |
|
196 |
</td> |
|
197 |
</tr> |
|
198 |
<tr> |
|
199 |
<td style="width:100px"> |
|
200 |
<div style="margin-left:auto;margin-right:0;background:#dcdcdc;width:<%= $branch->{status}{behind_bar} %>%;height:4px"></div> |
|
201 |
</td> |
|
202 |
<td class="ahead-behind-separate"> |
|
203 |
</td> |
|
204 |
<td style="width:100px"> |
|
205 |
<div style="background:#dcdcdc;width:<%= $branch->{status}{ahead_bar} %>%;height:4px"></div> |
|
206 |
</td> |
|
207 |
</tr> |
|
208 |
</table> |
|
209 |
% } |
|
210 |
</li> |
|
211 |
<li class="last-child"> |
|
212 |
% if ($branch_name eq $default_branch_name) { |
|
213 |
% if ($api->logined($user_id)) { |
|
214 |
<a href="<%= url_for("/$user_id/$project_id/settings#form-default-branch") %>" type="submit" class="btn btn-small">Change default branch</a> |
|
215 |
% } |
|
216 |
% } else { |
|
217 |
% if ($api->logined) { |
|
218 |
% if ($pull_request) { |
|
219 |
#<%= $issue->{number} %> |
|
220 |
% if ($issue->{open}) { |
|
221 |
<a class="branches-open" href="<%= url_for("/$user/$project/pull/$issue->{number}") %>"> |
|
222 |
open |
|
223 |
</a> |
|
fix bug that repository with...
|
224 |
% } else { |
simplify branches
|
225 |
<a class="branches-close" href="<%= url_for("/$user/$project/pull/$issue->{number}") %>"> |
226 |
closed |
|
improve branches page open c...
|
227 |
</a> |
228 |
% } |
|
229 |
% } else { |
|
simplify branches
|
230 |
<% |
231 |
my $compare_url; |
|
232 |
if ($original_project) { |
|
233 |
my $original_user_id = $original_project->{'user.id'}; |
|
234 |
my $original_project_id = $original_project->{id}; |
|
235 |
|
|
236 |
my $exists_original_branch_name = app->git->exists_branch( |
|
237 |
app->rep_info($original_user_id, $original_project_id), |
|
238 |
$branch_name |
|
239 |
); |
|
240 |
if ($exists_original_branch_name) { |
|
241 |
$compare_url = url_for("/$original_user_id/$original_project_id/compare/$branch_name...$user_id:$branch_name")->query(expand => 1); |
|
242 |
} |
|
243 |
else { |
|
244 |
my $original_project_default_branch = app->manager->default_branch($original_user_id, $original_project_id); |
|
245 |
$compare_url = url_for("/$original_user_id/$original_project_id/compare/$original_project_default_branch...$user_id:$branch_name")->query(expand => 1); |
|
246 |
} |
|
247 |
} |
|
248 |
else { |
|
249 |
$compare_url = url_for("/$user_id/$project_id/compare/$branch_name")->query(expand => 1); |
|
250 |
} |
|
251 |
%> |
|
252 |
<a class="btn btn-small" href="<%= $compare_url %>"> |
|
253 |
New pull request |
|
improve branches page open c...
|
254 |
</a> |
255 |
% } |
|
simplify branches
|
256 |
% } else { |
257 |
<a class="btn btn-small" href="<%= url_for("/$user_id/$project_id/compare/$branch_name")->query(expand => 1) %>"> |
|
258 |
Compare |
|
259 |
</a> |
|
260 |
% } |
|
261 |
% if ($api->logined($user_id)) { |
|
262 |
% if ($pull_request && $issue->{open}) { |
|
263 |
<button class="btn btn-small disabled delete-branch"value="Delete">Delete</button> |
|
264 |
% } else { |
|
265 |
<form action="<%= url_for->query(op => 'delete') %>" method="post" style="display:inline-block"> |
|
266 |
<input type="submit" class="btn btn-small delete-branch" style="color:#900;" value="Delete"> |
|
267 |
%= hidden_field branch => $branch_name; |
|
268 |
</form> |
|
imrpove branches page
|
269 |
% } |
improve branches design
|
270 |
% } |
simplify branches
|
271 |
% } |
272 |
</li> |
|
273 |
</ul> |
|
274 |
</li> |
|
improve tags page design
|
275 |
% $branches_count++; |
276 |
% } |
|
277 | ||
278 | ||
simplify branches
|
279 |
<div class="pagenation-container" style="margin-top:20px"> |
280 |
<ul class="pagenation"> |
|
281 |
% if ($page == 1) { |
|
282 |
<li><span>Newer</span></li> |
|
283 |
% } else { |
|
284 |
% my $newer_page = $page - 1; |
|
285 |
<li> |
|
fix branch paging
|
286 |
<a href="<%= url_for("/$user_id/$project_id/branches?page=$newer_page") %>">Newer</a> |
simplify branches
|
287 |
</li> |
288 |
% } |
|
289 |
% if ($branches_count < $page_count) { |
|
290 |
<li><span>Older</span></li> |
|
291 |
% } else { |
|
292 |
% my $older_page = $page + 1; |
|
293 |
<li> |
|
fix branch paging
|
294 |
<a href="<%= url_for("/$user_id/$project_id/branches?page=$older_page") %>">Older</a> |
simplify branches
|
295 |
</li> |
296 |
% } |
|
297 |
</ul> |
|
298 |
</div> |
|
improve branches design
|
299 |
% } else { |
300 |
<li style="text-align:center;text-color:#767676"> |
|
simplify branches
|
301 |
There aren’t any branches. |
improve some branches page
|
302 |
</li> |
303 |
% } |
|
304 |
</ul> |
|
305 |
% } |
|
added branches link
|
306 |
</div> |
design branches page
|
307 |
|
308 |
%= include '/include/footer'; |