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