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 some branches page
|
9 |
my $display = param('display') || 'overview'; |
improve tags page design
|
10 |
my $page = param('page') || 1; |
added Tags link
|
11 |
|
12 |
# Git |
|
revert encoding support
|
13 |
my $git = $self->app->git; |
added branch deleting featur...
|
14 | |
15 |
# Delete |
|
16 |
my $errors; |
|
fix branch not deleted bug a...
|
17 |
if ($op eq 'delete' && lc $self->req->method eq 'post') { |
18 |
|
|
19 |
# Forbbiden |
|
improve branches page open c...
|
20 |
unless ($api->logined($user_id)) { |
fix branch not deleted bug a...
|
21 |
$self->redirect_to('/'); |
22 |
return; |
|
23 |
} |
|
cleanup branch page validati...
|
24 |
|
25 |
# Parameters |
|
26 |
my $branch = param('branch'); |
|
27 |
|
|
28 |
# Validator |
|
29 |
my $vc = app->vc; |
|
30 |
|
|
31 |
# Validation result |
|
32 |
my $validation = $vc->validation; |
|
33 |
|
|
34 |
# "branch" |
|
35 |
if (!(defined $branch && length $branch)) { |
|
36 |
$validation->add_failed(branch => 'Branch name is empty'); |
|
37 |
} |
|
added branch deleting featur...
|
38 | |
cleanup branch page validati...
|
39 |
if ($validation->is_valid) { |
added branch deleting featur...
|
40 |
# Delete branch |
improve branches page open c...
|
41 |
eval { $git->delete_branch(app->rep_info($user_id, $project_id), $branch) }; |
improve error message
|
42 |
if (my $e = $@) { |
43 |
app->log->error(url_with . ": $e"); |
|
fix branch not deleted bug a...
|
44 |
$errors = ['Internal Error']; |
added branch deleting featur...
|
45 |
} |
46 |
else { |
|
fix branch not deleted bug a...
|
47 |
$self->flash(message => "Branch $branch is deleted."); |
48 |
$self->redirect_to; |
|
added branch deleting featur...
|
49 |
return; |
50 |
} |
|
51 |
} |
|
cleanup branch page validati...
|
52 |
else { $errors = $validation->messages } |
added branch deleting featur...
|
53 |
} |
fix branch not deleted bug a...
|
54 |
|
55 |
# Default branch |
|
improve branches page open c...
|
56 |
my $default_branch_name = app->manager->default_branch($user_id, $project_id); |
57 |
my $default_branch = $git->branch($self->app->rep_info($user_id, $project_id), $default_branch_name); |
|
improve some branches page
|
58 |
|
59 |
# Branches |
|
improve branches design
|
60 |
my $branch_types; |
improve some branches page
|
61 |
my $branches_h = { |
62 |
default => [], |
|
63 |
active => [], |
|
64 |
stale => [], |
|
65 |
all => [] |
|
66 |
}; |
|
improve tags page design
|
67 | |
68 |
# Pagenation |
|
69 |
my $page_count = 20; |
|
70 |
my $skip = $page_count * ($page - 1); |
|
fix branch not deleted bug a...
|
71 |
|
improve branches page open c...
|
72 |
my $branches = $git->branches($self->app->rep_info($user_id, $project_id)); |
fix branch not deleted bug a...
|
73 |
my $max = 0; |
improve tags page design
|
74 |
my $active_count = 0; |
75 |
my $stale_count = 0; |
|
76 |
my $all_count = 0; |
|
fix branch not deleted bug a...
|
77 |
for my $branch (@$branches) { |
cleanup branch_status
|
78 |
$branch->{status} = $git->branch_status( |
improve branches page open c...
|
79 |
$self->app->rep_info($user_id, $project_id), |
cleanup rep_info
|
80 |
$default_branch->{name}, |
81 |
$branch->{name} |
|
cleanup branch_status
|
82 |
); |
fix branch not deleted bug a...
|
83 |
$max = $branch->{status}{ahead} if $max < $branch->{status}{ahead}; |
84 |
$max = $branch->{status}{behind} if $max < $branch->{status}{behind}; |
|
improve some branches page
|
85 |
|
fix branches bar
|
86 |
if ($branch->{status}{ahead} > 100) { |
87 |
$branch->{status}{ahead_bar} = 100; |
|
88 |
} |
|
89 |
else { |
|
90 |
$branch->{status}{ahead_bar} = $branch->{status}{ahead}; |
|
91 |
} |
|
92 |
if ($branch->{status}{behind} > 100) { |
|
93 |
$branch->{status}{behind_bar} = 100; |
|
94 |
} |
|
95 |
else { |
|
96 |
$branch->{status}{behind_bar} = $branch->{status}{behind}; |
|
97 |
} |
|
98 |
|
|
99 |
$max = 100 if $max > 100; |
|
100 |
|
|
improve branch design
|
101 |
my $branch_type; |
102 |
if ($branch->{name} eq $default_branch_name) { |
|
103 |
$branch_type = 'default'; |
|
104 |
} |
|
105 |
elsif ($branch->{commit}{age} < 60 * 60 * 24 * (365 * 3)) { |
|
106 |
$branch_type = 'active'; |
|
107 |
} |
|
108 |
else { |
|
109 |
$branch_type = 'stale'; |
|
110 |
} |
|
separate active, stale
|
111 |
|
improve some branches page
|
112 |
if ($display eq 'overview') { |
improve branch design
|
113 |
if ($branch_type eq 'default') { |
improve some branches page
|
114 |
push @{$branches_h->{default}}, $branch; |
115 |
} |
|
improve branch design
|
116 |
elsif ($branch_type eq 'active') { |
117 |
push @{$branches_h->{active}}, $branch; |
|
118 |
} |
|
119 |
elsif ($branch_type eq 'stale') { |
|
120 |
push @{$branches_h->{stale}}, $branch; |
|
improve some branches page
|
121 |
} |
122 |
} |
|
123 |
elsif ($display eq 'active') { |
|
improve branch design
|
124 |
if ($branch_type eq 'active') { |
improve tags page design
|
125 |
if ($active_count >= $skip && $active_count < $skip + $page_count) { |
126 |
push @{$branches_h->{active}}, $branch; |
|
127 |
} |
|
128 |
$active_count++; |
|
separate active, stale
|
129 |
} |
improve some branches page
|
130 |
} |
131 |
elsif ($display eq 'stale') { |
|
improve branch design
|
132 |
if ($branch_type eq 'stale') { |
improve tags page design
|
133 |
if ($stale_count >= $skip && $stale_count < $skip + $page_count) { |
134 |
push @{$branches_h->{stale}}, $branch; |
|
135 |
} |
|
136 |
$stale_count++; |
|
separate active, stale
|
137 |
} |
improve some branches page
|
138 |
} |
139 |
elsif ($display eq 'all') { |
|
improve tags page design
|
140 |
if ($all_count >= $skip && $all_count < $skip + $page_count) { |
141 |
push @{$branches_h->{all}}, $branch; |
|
142 |
} |
|
143 |
$all_count++; |
|
improve some branches page
|
144 |
} |
added branch deleting featur...
|
145 |
} |
improve tags page design
|
146 |
|
fix branches page pull reque...
|
147 |
my $original_project_row_id = app->dbi->model('project')->select( |
148 |
'original_project', |
|
remove table __ prefix
|
149 |
where => {'user.id' => $user_id, 'project.id' => $project_id} |
fix branches page pull reque...
|
150 |
)->value; |
151 |
|
|
152 |
my $original_project; |
|
153 |
if ($original_project_row_id) { |
|
154 |
$original_project = app->dbi->model('project')->select( |
|
155 |
[ |
|
156 |
{__MY__ => '*'}, |
|
remove table __ prefix
|
157 |
{user => ['id']} |
fix branches page pull reque...
|
158 |
], |
159 |
where => {'project.row_id' => $original_project_row_id} |
|
160 |
)->one; |
|
161 |
} |
|
added Tags link
|
162 |
%> |
163 | ||
improve branches page open c...
|
164 |
% layout 'common', title => "branches \x{30fb} $user_id/$project_id"; |
added merged branches to bra...
|
165 | |
cleanup
|
166 |
%= include '/include/header'; |
cleanup
|
167 |
|
added branch deleting featur...
|
168 |
<div class="container" style="padding-bottom:30px"> |
fix branch not deleted bug a...
|
169 |
%= include '/include/errors', errors => $errors; |
170 |
%= include '/include/message', message => flash('message'); |
|
added branch deleting featur...
|
171 |
|
improve some branches page
|
172 |
<!-- Branches (for tests) --> |
design branches page
|
173 |
|
improve branches design
|
174 |
<ul class="branches-select"> |
175 |
<li class="<%= $display eq 'overview' ? 'active' : '' %>"> |
|
improve branches page open c...
|
176 |
<a href="<%= url_for("/$user_id/$project_id/branches") %>">Overview</a> |
improve some branches page
|
177 |
</li> |
improve branches design
|
178 |
<li class="<%= $display eq 'active' ? 'active' : '' %>"> |
improve branches page open c...
|
179 |
<a href="<%= url_for("/$user_id/$project_id/branches/active") %>">Active</a> |
improve some branches page
|
180 |
</li> |
improve branches design
|
181 |
<li class="<%= $display eq 'stale' ? 'active' : '' %>"> |
improve branches page open c...
|
182 |
<a href="<%= url_for("/$user_id/$project_id/branches/stale") %>">Stale</a> |
improve some branches page
|
183 |
</li> |
improve branches design
|
184 |
<li class="<%= $display eq 'all' ? 'active' : '' %>"> |
improve branches page open c...
|
185 |
<a href="<%= url_for("/$user_id/$project_id/branches/all") %>">All branches</a> |
improve some branches page
|
186 |
</li> |
187 |
</ul> |
|
improve branches design
|
188 |
<% |
189 |
if ($display eq 'overview') { |
|
190 |
$branch_types = ['default', 'active', 'stale']; |
|
191 |
} |
|
192 |
elsif ($display eq 'active') { |
|
193 |
$branch_types = ['active']; |
|
194 |
} |
|
195 |
elsif ($display eq 'stale') { |
|
196 |
$branch_types = ['stale']; |
|
197 |
} |
|
198 |
elsif ($display eq 'all') { |
|
199 |
$branch_types = ['all']; |
|
200 |
} |
|
201 |
%> |
|
improve some branches page
|
202 |
|
203 |
% for my $branch_type (@$branch_types) { |
|
204 |
% my $branches = $branches_h->{$branch_type}; |
|
improve branches design
|
205 |
|
206 |
% if (@$branches || $display ne 'overview') { |
|
improve branch design
|
207 |
<ul class="branches"> |
208 |
<li> |
|
209 |
% if ($branch_type eq 'default') { |
|
210 |
Default branch |
|
211 |
% } elsif ($branch_type eq 'active') { |
|
212 |
Active branch |
|
213 |
% } elsif ($branch_type eq 'stale') { |
|
214 |
Stale branch |
|
215 |
% } elsif ($branch_type eq 'all') { |
|
216 |
All branches |
|
217 |
% } |
|
218 |
</li> |
|
improve branches design
|
219 |
% if (@$branches) { |
improve tags page design
|
220 |
% my $branches_count; |
improve branches design
|
221 |
% for (my $i = 0; $i < @$branches; $i++) { |
imrpove branches page
|
222 |
<% |
223 |
my $branch = $branches->[$i]; |
|
improve branches page open c...
|
224 |
my $branch_name = $branch->{name}; |
add user page link from user...
|
225 | |
cleanup
|
226 |
my $commit_author_email = $branch->{commit}{author_email}; |
add user page link from user...
|
227 |
my $commit_author_id = app->dbi->model('user')->select( |
228 |
'id', |
|
fix mail bug
|
229 |
where => {email => $commit_author_email} |
add user page link from user...
|
230 |
)->value; |
improve branches page open c...
|
231 | |
232 |
my $pull_request = app->dbi->model('pull_request')->select( |
|
fix branches page bug
|
233 |
{__MY__ => ['row_id']}, |
improve branches page open c...
|
234 |
where => { |
remove table __ prefix
|
235 |
'base_project.id' => $project_id, |
236 |
'base_project__user.id' => $user_id, |
|
fix pull_request table bug
|
237 |
base_branch => $default_branch_name, |
238 |
target_branch => $branch_name |
|
improve branches page open c...
|
239 |
} |
240 |
)->one; |
|
fix branches page
|
241 |
|
242 |
my $issue; |
|
243 |
if ($pull_request) { |
|
244 |
$issue = app->dbi->model('issue')->select( |
|
245 |
where => {pull_request => $pull_request->{row_id}} |
|
246 |
)->one; |
|
247 |
} |
|
248 |
|
|
imrpove branches page
|
249 |
%> |
250 |
% if ($display eq 'overview' && $i > 4) { |
|
251 |
<li class="branches-overview-more"> |
|
improve branches page open c...
|
252 |
<a href="<%= url_for("/$user_id/$project_id/branches/$branch_type") %>"> |
imrpove branches page
|
253 |
View more <%= $branch_type %> branches |
254 |
</a> |
|
255 |
</li> |
|
256 |
% last; |
|
257 |
% } else { |
|
258 | ||
259 |
<li> |
|
260 |
<ul> |
|
261 |
<li> |
|
262 |
<div class="branches-name"> |
|
improve branches page open c...
|
263 |
<a href="<%= url_for("/$user_id/$project_id/tree/$branch_name") %>"> |
264 |
<%= $branch_name %> |
|
imrpove branches page
|
265 |
</a> |
improve branches design
|
266 |
</div> |
imrpove branches page
|
267 |
<div class="branches-age" title="<%= $branch->{commit}{age_string_datetime_local} %>"> |
268 |
Updated <%= $branch->{commit}{age_string} %> by |
|
269 |
</div> |
|
270 |
<div class="branches-author" title="<%= $branch->{commit}{author_email} %>"> |
|
add user page link from user...
|
271 |
% if (defined $commit_author_id) { |
272 |
<a href="<%= url_for("/$commit_author_id") %>"><%= $commit_author_id %></a> |
|
273 |
% } else { |
|
274 |
<%= $branch->{commit}{author_name} %> |
|
275 |
% } |
|
imrpove branches page
|
276 |
</div> |
277 |
</li> |
|
278 |
<li class="second-child"> |
|
improve branches page open c...
|
279 |
% if ($branch_name eq $default_branch_name) { |
imrpove branches page
|
280 |
<div style="padding-left:80px;padding-top:3px"> |
281 |
<div class="branches-default"> |
|
282 |
Default |
|
283 |
</div> |
|
284 |
</div> |
|
285 |
% } else { |
|
286 |
<table class="ahead-behind"> |
|
287 |
<tr> |
|
288 |
<td class="ahead-behind-behind-count"> |
|
289 |
<%= $branch->{status}{behind} %> |
|
290 |
</td> |
|
291 |
<td class="ahead-behind-separate"> |
|
292 |
</td> |
|
293 |
<td style="padding-left:3px"> |
|
294 |
<%= $branch->{status}{ahead} %> |
|
295 |
</td> |
|
296 |
</tr> |
|
297 |
<tr> |
|
298 |
<td style="width:100px"> |
|
fix branches bar
|
299 |
<div style="margin-left:auto;margin-right:0;background:#dcdcdc;width:<%= $branch->{status}{behind_bar} %>%;height:4px"></div> |
imrpove branches page
|
300 |
</td> |
301 |
<td class="ahead-behind-separate"> |
|
302 |
</td> |
|
303 |
<td style="width:100px"> |
|
fix branches bar
|
304 |
<div style="background:#dcdcdc;width:<%= $branch->{status}{ahead_bar} %>%;height:4px"></div> |
imrpove branches page
|
305 |
</td> |
306 |
</tr> |
|
307 |
</table> |
|
improve branches design
|
308 |
% } |
imrpove branches page
|
309 |
</li> |
310 |
<li class="last-child"> |
|
improve branches page open c...
|
311 |
% if ($branch_name eq $default_branch_name) { |
312 |
% if ($api->logined($user_id)) { |
|
313 |
<a href="<%= url_for("/$user_id/$project_id/settings#form-default-branch") %>" type="submit" class="btn btn-small">Change default branch</a> |
|
imrpove branches page
|
314 |
% } |
315 |
% } else { |
|
improve branches page open c...
|
316 |
% if ($api->logined) { |
317 |
% if ($pull_request) { |
|
fix branches page
|
318 |
% if ($issue->{open}) { |
319 |
#<%= $issue->{row_id} %> |
|
320 |
<a class="branches-open" href="<%= url_for("/$user/$project/pull/$issue->{row_id}") %>"> |
|
improve branches page open c...
|
321 |
open |
322 |
</a> |
|
323 |
% } else { |
|
fix branches page
|
324 |
<a class="branches-close" href="<%= url_for("/$user/$project/pull/$issue->{row_id}") %>"> |
cleanup merge and push logic
|
325 |
closed |
326 |
</a> |
|
improve branches page open c...
|
327 |
% } |
fix bug that repository with...
|
328 |
% } else { |
fix branches page pull reque...
|
329 |
<% |
330 |
my $compare_url; |
|
331 |
if ($original_project) { |
|
remove table __ prefix
|
332 |
my $original_user_id = $original_project->{'user.id'}; |
fix branches page pull reque...
|
333 |
my $original_project_id = $original_project->{id}; |
334 |
|
|
335 |
my $exists_original_branch_name = app->git->exists_branch( |
|
336 |
app->rep_info($original_user_id, $original_project_id), |
|
337 |
$branch_name |
|
338 |
); |
|
339 |
if ($exists_original_branch_name) { |
|
340 |
$compare_url = url_for("/$original_user_id/$original_project_id/compare/$branch_name...$user_id:$branch_name")->query(expand => 1); |
|
341 |
} |
|
342 |
else { |
|
343 |
my $original_project_default_branch = app->manager->default_branch($original_user_id, $original_project_id); |
|
344 |
$compare_url = url_for("/$original_user_id/$original_project_id/compare/$original_project_default_branch...$user_id:$branch_name")->query(expand => 1); |
|
345 |
} |
|
346 |
} |
|
347 |
else { |
|
348 |
$compare_url = url_for("/$user_id/$project_id/compare/$branch_name")->query(expand => 1); |
|
349 |
} |
|
350 |
%> |
|
351 |
<a class="btn btn-small" href="<%= $compare_url %>"> |
|
improve branches page open c...
|
352 |
New pull request |
353 |
</a> |
|
354 |
% } |
|
355 |
% } else { |
|
356 |
<a class="btn btn-small" href="<%= url_for("/$user_id/$project_id/compare/$branch_name")->query(expand => 1) %>"> |
|
fix bug that repository with...
|
357 |
Compare |
improve branches page open c...
|
358 |
</a> |
359 |
% } |
|
360 |
% if ($api->logined($user_id)) { |
|
fix branches page
|
361 |
% if ($pull_request && $issue->{open}) { |
improve branches page open c...
|
362 |
<button class="btn btn-small disabled delete-branch"value="Delete">Delete</button> |
363 |
% } else { |
|
364 |
<form action="<%= url_for->query(op => 'delete') %>" method="post" style="display:inline-block"> |
|
365 |
<input type="submit" class="btn btn-small delete-branch" style="color:#900;" value="Delete"> |
|
366 |
%= hidden_field branch => $branch_name; |
|
367 |
</form> |
|
fix bug that repository with...
|
368 |
% } |
imrpove branches page
|
369 |
% } |
improve branches design
|
370 |
% } |
imrpove branches page
|
371 |
</li> |
372 |
</ul> |
|
373 |
</li> |
|
374 |
% } |
|
improve tags page design
|
375 |
% $branches_count++; |
376 |
% } |
|
377 | ||
378 | ||
379 |
% if ($display ne 'overview') { |
|
380 |
<div class="pagenation-container" style="margin-top:20px"> |
|
381 |
<ul class="pagenation"> |
|
382 |
% if ($page == 1) { |
|
383 |
<li><span>Newer</span></li> |
|
384 |
% } else { |
|
385 |
% my $newer_page = $page - 1; |
|
386 |
<li> |
|
improve branches page open c...
|
387 |
<a href="<%= url_for("/$user_id/$project_id/branches/$display?page=$newer_page") %>">Newer</a> |
improve tags page design
|
388 |
</li> |
389 |
% } |
|
390 |
% if ($branches_count < $page_count) { |
|
391 |
<li><span>Older</span></li> |
|
392 |
% } else { |
|
393 |
% my $older_page = $page + 1; |
|
394 |
<li> |
|
improve branches page open c...
|
395 |
<a href="<%= url_for("/$user_id/$project_id/branches/$display?page=$older_page") %>">Older</a> |
improve tags page design
|
396 |
</li> |
397 |
% } |
|
398 |
</ul> |
|
399 |
</div> |
|
improve branches design
|
400 |
% } |
401 |
% } else { |
|
402 |
<li style="text-align:center;text-color:#767676"> |
|
403 |
<% |
|
404 |
my $branch_type_name; |
|
405 |
if ($branch_type eq 'active' || $branch_type eq 'stale') { |
|
406 |
$branch_type_name = $branch_type; |
|
407 |
} |
|
408 |
else { |
|
409 |
$branch_type_name = ''; |
|
410 |
} |
|
411 |
%> |
|
412 |
|
|
413 |
There aren’t any <%= $branch_type_name %> branches. |
|
improve some branches page
|
414 |
</li> |
415 |
% } |
|
416 |
</ul> |
|
417 |
% } |
|
cleanup branches page
|
418 |
% } |
added branches link
|
419 |
</div> |
design branches page
|
420 |
|
421 |
%= include '/include/footer'; |