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 |
fix branch not deleted bug a...
|
42 |
eval { $git->delete_branch($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); |
58 |
my $default_branch = $git->branch($user, $project, $default_branch_name); |
|
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 |
|
73 |
my $branches = $git->branches($user, $project); |
|
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) { |
improve some branches page
|
79 |
$branch->{status} = $git->branch_status($user, $project, $default_branch->{name}, $branch->{name}); |
fix branch not deleted bug a...
|
80 |
$max = $branch->{status}{ahead} if $max < $branch->{status}{ahead}; |
81 |
$max = $branch->{status}{behind} if $max < $branch->{status}{behind}; |
|
improve some branches page
|
82 |
|
fix branches bar
|
83 |
if ($branch->{status}{ahead} > 100) { |
84 |
$branch->{status}{ahead_bar} = 100; |
|
85 |
} |
|
86 |
else { |
|
87 |
$branch->{status}{ahead_bar} = $branch->{status}{ahead}; |
|
88 |
} |
|
89 |
if ($branch->{status}{behind} > 100) { |
|
90 |
$branch->{status}{behind_bar} = 100; |
|
91 |
} |
|
92 |
else { |
|
93 |
$branch->{status}{behind_bar} = $branch->{status}{behind}; |
|
94 |
} |
|
95 |
|
|
96 |
$max = 100 if $max > 100; |
|
97 |
|
|
improve branch design
|
98 |
my $branch_type; |
99 |
if ($branch->{name} eq $default_branch_name) { |
|
100 |
$branch_type = 'default'; |
|
101 |
} |
|
102 |
elsif ($branch->{commit}{age} < 60 * 60 * 24 * (365 * 3)) { |
|
103 |
$branch_type = 'active'; |
|
104 |
} |
|
105 |
else { |
|
106 |
$branch_type = 'stale'; |
|
107 |
} |
|
separate active, stale
|
108 |
|
improve some branches page
|
109 |
if ($display eq 'overview') { |
improve branch design
|
110 |
if ($branch_type eq 'default') { |
improve some branches page
|
111 |
push @{$branches_h->{default}}, $branch; |
112 |
} |
|
improve branch design
|
113 |
elsif ($branch_type eq 'active') { |
114 |
push @{$branches_h->{active}}, $branch; |
|
115 |
} |
|
116 |
elsif ($branch_type eq 'stale') { |
|
117 |
push @{$branches_h->{stale}}, $branch; |
|
improve some branches page
|
118 |
} |
119 |
} |
|
120 |
elsif ($display eq 'active') { |
|
improve branch design
|
121 |
if ($branch_type eq 'active') { |
improve tags page design
|
122 |
if ($active_count >= $skip && $active_count < $skip + $page_count) { |
123 |
push @{$branches_h->{active}}, $branch; |
|
124 |
} |
|
125 |
$active_count++; |
|
separate active, stale
|
126 |
} |
improve some branches page
|
127 |
} |
128 |
elsif ($display eq 'stale') { |
|
improve branch design
|
129 |
if ($branch_type eq 'stale') { |
improve tags page design
|
130 |
if ($stale_count >= $skip && $stale_count < $skip + $page_count) { |
131 |
push @{$branches_h->{stale}}, $branch; |
|
132 |
} |
|
133 |
$stale_count++; |
|
separate active, stale
|
134 |
} |
improve some branches page
|
135 |
} |
136 |
elsif ($display eq 'all') { |
|
improve tags page design
|
137 |
if ($all_count >= $skip && $all_count < $skip + $page_count) { |
138 |
push @{$branches_h->{all}}, $branch; |
|
139 |
} |
|
140 |
$all_count++; |
|
improve some branches page
|
141 |
} |
added branch deleting featur...
|
142 |
} |
improve tags page design
|
143 |
|
added Tags link
|
144 |
%> |
145 | ||
add title
|
146 |
% layout 'common', title => "branches \x{30fb} $user/$project"; |
added merged branches to bra...
|
147 | |
cleanup
|
148 |
%= include '/include/header'; |
cleanup
|
149 |
|
added branch deleting featur...
|
150 |
<div class="container" style="padding-bottom:30px"> |
fix branch not deleted bug a...
|
151 |
%= include '/include/errors', errors => $errors; |
152 |
%= include '/include/message', message => flash('message'); |
|
added branch deleting featur...
|
153 |
|
improve some branches page
|
154 |
<!-- Branches (for tests) --> |
design branches page
|
155 |
|
improve branches design
|
156 |
<ul class="branches-select"> |
157 |
<li class="<%= $display eq 'overview' ? 'active' : '' %>"> |
|
improve some branches page
|
158 |
<a href="<%= url_for("/$user/$project/branches") %>">Overview</a> |
159 |
</li> |
|
improve branches design
|
160 |
<li class="<%= $display eq 'active' ? 'active' : '' %>"> |
improve some branches page
|
161 |
<a href="<%= url_for("/$user/$project/branches/active") %>">Active</a> |
162 |
</li> |
|
improve branches design
|
163 |
<li class="<%= $display eq 'stale' ? 'active' : '' %>"> |
improve some branches page
|
164 |
<a href="<%= url_for("/$user/$project/branches/stale") %>">Stale</a> |
165 |
</li> |
|
improve branches design
|
166 |
<li class="<%= $display eq 'all' ? 'active' : '' %>"> |
improve some branches page
|
167 |
<a href="<%= url_for("/$user/$project/branches/all") %>">All branches</a> |
168 |
</li> |
|
169 |
</ul> |
|
improve branches design
|
170 |
<% |
171 |
if ($display eq 'overview') { |
|
172 |
$branch_types = ['default', 'active', 'stale']; |
|
173 |
} |
|
174 |
elsif ($display eq 'active') { |
|
175 |
$branch_types = ['active']; |
|
176 |
} |
|
177 |
elsif ($display eq 'stale') { |
|
178 |
$branch_types = ['stale']; |
|
179 |
} |
|
180 |
elsif ($display eq 'all') { |
|
181 |
$branch_types = ['all']; |
|
182 |
} |
|
183 |
%> |
|
improve some branches page
|
184 |
|
185 |
% for my $branch_type (@$branch_types) { |
|
186 |
% my $branches = $branches_h->{$branch_type}; |
|
improve branches design
|
187 |
|
188 |
% if (@$branches || $display ne 'overview') { |
|
improve branch design
|
189 |
<ul class="branches"> |
190 |
<li> |
|
191 |
% if ($branch_type eq 'default') { |
|
192 |
Default branch |
|
193 |
% } elsif ($branch_type eq 'active') { |
|
194 |
Active branch |
|
195 |
% } elsif ($branch_type eq 'stale') { |
|
196 |
Stale branch |
|
197 |
% } elsif ($branch_type eq 'all') { |
|
198 |
All branches |
|
199 |
% } |
|
200 |
</li> |
|
improve branches design
|
201 |
% if (@$branches) { |
improve tags page design
|
202 |
% my $branches_count; |
improve branches design
|
203 |
% for (my $i = 0; $i < @$branches; $i++) { |
imrpove branches page
|
204 |
<% |
205 |
my $branch = $branches->[$i]; |
|
206 |
my $bname = $branch->{name}; |
|
207 |
%> |
|
208 |
% if ($display eq 'overview' && $i > 4) { |
|
209 |
<li class="branches-overview-more"> |
|
210 |
<a href="<%= url_for("/$user/$project/branches/$branch_type") %>"> |
|
211 |
View more <%= $branch_type %> branches |
|
212 |
</a> |
|
213 |
</li> |
|
214 |
% last; |
|
215 |
% } else { |
|
216 | ||
217 |
<li> |
|
218 |
<ul> |
|
219 |
<li> |
|
220 |
<div class="branches-name"> |
|
221 |
<a href="<%= url_for("/$user/$project/tree/$bname") %>"> |
|
222 |
<%= $bname %> |
|
223 |
</a> |
|
improve branches design
|
224 |
</div> |
imrpove branches page
|
225 |
<div class="branches-age" title="<%= $branch->{commit}{age_string_datetime_local} %>"> |
226 |
Updated <%= $branch->{commit}{age_string} %> by |
|
227 |
</div> |
|
228 |
<div class="branches-author" title="<%= $branch->{commit}{author_email} %>"> |
|
229 |
<%= $branch->{commit}{author_name} %> |
|
230 |
</div> |
|
231 |
</li> |
|
232 |
<li class="second-child"> |
|
233 |
% if ($bname eq $default_branch_name) { |
|
234 |
<div style="padding-left:80px;padding-top:3px"> |
|
235 |
<div class="branches-default"> |
|
236 |
Default |
|
237 |
</div> |
|
238 |
</div> |
|
239 |
% } else { |
|
240 |
<table class="ahead-behind"> |
|
241 |
<tr> |
|
242 |
<td class="ahead-behind-behind-count"> |
|
243 |
<%= $branch->{status}{behind} %> |
|
244 |
</td> |
|
245 |
<td class="ahead-behind-separate"> |
|
246 |
</td> |
|
247 |
<td style="padding-left:3px"> |
|
248 |
<%= $branch->{status}{ahead} %> |
|
249 |
</td> |
|
250 |
</tr> |
|
251 |
<tr> |
|
252 |
<td style="width:100px"> |
|
fix branches bar
|
253 |
<div style="margin-left:auto;margin-right:0;background:#dcdcdc;width:<%= $branch->{status}{behind_bar} %>%;height:4px"></div> |
imrpove branches page
|
254 |
</td> |
255 |
<td class="ahead-behind-separate"> |
|
256 |
</td> |
|
257 |
<td style="width:100px"> |
|
fix branches bar
|
258 |
<div style="background:#dcdcdc;width:<%= $branch->{status}{ahead_bar} %>%;height:4px"></div> |
imrpove branches page
|
259 |
</td> |
260 |
</tr> |
|
261 |
</table> |
|
improve branches design
|
262 |
% } |
imrpove branches page
|
263 |
</li> |
264 |
<li class="last-child"> |
|
265 |
% if ($bname eq $default_branch_name) { |
|
266 |
% if ($api->logined($user)) { |
|
267 |
<a href="<%= url_for("/$user/$project/settings") %>" type="submit" class="btn btn-small">Change default branch</a> |
|
268 |
% } |
|
269 |
% } else { |
|
270 |
<a class="btn btn-small" href="<%= url_for("/$user/$project/compare/$default_branch->{name}...$bname") %>"> |
|
271 |
Compare |
|
272 |
</a> |
|
273 |
% if ($api->logined($user)) { |
|
274 |
<form action="<%= url_for->query(op => 'delete') %>" method="post" style="display:inline-block"> |
|
275 |
<input type="submit" class="btn btn-small delete-branch" style="color:#900;" value="Delete"> |
|
276 |
%= hidden_field branch => $bname; |
|
277 |
</form> |
|
278 |
% } |
|
279 |
% if (app->config->{basic}{show_ignore_space_change_link}) { |
|
280 |
(<a style="font-size:90%;color:#9999FF" href="<%= url_for("/$user/$project/compare/$default_branch->{name}...$bname?w=") %>"> |
|
281 |
ignore space |
|
282 |
</a>) |
|
283 |
% } |
|
improve branches design
|
284 |
% } |
imrpove branches page
|
285 |
</li> |
286 |
</ul> |
|
287 |
</li> |
|
288 |
% } |
|
improve tags page design
|
289 |
% $branches_count++; |
290 |
% } |
|
291 | ||
292 | ||
293 |
% if ($display ne 'overview') { |
|
294 |
<div class="pagenation-container" style="margin-top:20px"> |
|
295 |
<ul class="pagenation"> |
|
296 |
% if ($page == 1) { |
|
297 |
<li><span>Newer</span></li> |
|
298 |
% } else { |
|
299 |
% my $newer_page = $page - 1; |
|
300 |
<li> |
|
301 |
<a href="<%= url_for("/$user/$project/branches/$display?page=$newer_page") %>">Newer</a> |
|
302 |
</li> |
|
303 |
% } |
|
304 |
% if ($branches_count < $page_count) { |
|
305 |
<li><span>Older</span></li> |
|
306 |
% } else { |
|
307 |
% my $older_page = $page + 1; |
|
308 |
<li> |
|
309 |
<a href="<%= url_for("/$user/$project/branches/$display?page=$older_page") %>">Older</a> |
|
310 |
</li> |
|
311 |
% } |
|
312 |
</ul> |
|
313 |
</div> |
|
improve branches design
|
314 |
% } |
315 |
% } else { |
|
316 |
<li style="text-align:center;text-color:#767676"> |
|
317 |
<% |
|
318 |
my $branch_type_name; |
|
319 |
if ($branch_type eq 'active' || $branch_type eq 'stale') { |
|
320 |
$branch_type_name = $branch_type; |
|
321 |
} |
|
322 |
else { |
|
323 |
$branch_type_name = ''; |
|
324 |
} |
|
325 |
%> |
|
326 |
|
|
327 |
There aren’t any <%= $branch_type_name %> branches. |
|
improve some branches page
|
328 |
</li> |
329 |
% } |
|
330 |
</ul> |
|
331 |
% } |
|
cleanup branches page
|
332 |
% } |
added branches link
|
333 |
</div> |
design branches page
|
334 |
|
335 |
%= include '/include/footer'; |