... | ... |
@@ -3356,13 +3356,7 @@ button.close { |
3356 | 3356 |
padding:8px 8px; |
3357 | 3357 |
} |
3358 | 3358 |
.branches > li:first-child { |
3359 |
- border-radius: 3px 3px 0 0; |
|
3360 | 3359 |
border-top:1px solid #e6e9e6; |
3361 |
- background: #f5f5f5; |
|
3362 |
- text-shadow: 0 1px 0 #fff; |
|
3363 |
-} |
|
3364 |
-.branches > li:last-child { |
|
3365 |
- border-radius: 0 0 3px 3px; |
|
3366 | 3360 |
} |
3367 | 3361 |
.branches > li > ul { |
3368 | 3362 |
overflow:hidden; |
... | ... |
@@ -6,7 +6,7 @@ |
6 | 6 |
my $user_id = param('user'); |
7 | 7 |
my $project_id = param('project'); |
8 | 8 |
my $op = param('op') || ''; |
9 |
- my $display = param('display') || 'overview'; |
|
9 |
+ my $display = 'all'; |
|
10 | 10 |
my $page = param('page') || 1; |
11 | 11 |
|
12 | 12 |
# Git |
... | ... |
@@ -58,12 +58,7 @@ |
58 | 58 |
|
59 | 59 |
# Branches |
60 | 60 |
my $branch_types; |
61 |
- my $branches_h = { |
|
62 |
- default => [], |
|
63 |
- active => [], |
|
64 |
- stale => [], |
|
65 |
- all => [] |
|
66 |
- }; |
|
61 |
+ my $branches = []; |
|
67 | 62 |
|
68 | 63 |
# Pagenation |
69 | 64 |
my $page_count = 20; |
... | ... |
@@ -71,8 +66,6 @@ |
71 | 66 |
|
72 | 67 |
my $branches = $git->branches($self->app->rep_info($user_id, $project_id)); |
73 | 68 |
my $max = 0; |
74 |
- my $active_count = 0; |
|
75 |
- my $stale_count = 0; |
|
76 | 69 |
my $all_count = 0; |
77 | 70 |
for my $branch (@$branches) { |
78 | 71 |
$branch->{status} = $git->branch_status( |
... | ... |
@@ -98,50 +91,10 @@ |
98 | 91 |
|
99 | 92 |
$max = 100 if $max > 100; |
100 | 93 |
|
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 |
- } |
|
111 |
- |
|
112 |
- if ($display eq 'overview') { |
|
113 |
- if ($branch_type eq 'default') { |
|
114 |
- push @{$branches_h->{default}}, $branch; |
|
115 |
- } |
|
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; |
|
121 |
- } |
|
122 |
- } |
|
123 |
- elsif ($display eq 'active') { |
|
124 |
- if ($branch_type eq 'active') { |
|
125 |
- if ($active_count >= $skip && $active_count < $skip + $page_count) { |
|
126 |
- push @{$branches_h->{active}}, $branch; |
|
127 |
- } |
|
128 |
- $active_count++; |
|
129 |
- } |
|
130 |
- } |
|
131 |
- elsif ($display eq 'stale') { |
|
132 |
- if ($branch_type eq 'stale') { |
|
133 |
- if ($stale_count >= $skip && $stale_count < $skip + $page_count) { |
|
134 |
- push @{$branches_h->{stale}}, $branch; |
|
135 |
- } |
|
136 |
- $stale_count++; |
|
137 |
- } |
|
138 |
- } |
|
139 |
- elsif ($display eq 'all') { |
|
140 |
- if ($all_count >= $skip && $all_count < $skip + $page_count) { |
|
141 |
- push @{$branches_h->{all}}, $branch; |
|
142 |
- } |
|
143 |
- $all_count++; |
|
94 |
+ if ($all_count >= $skip && $all_count < $skip + $page_count) { |
|
95 |
+ push @$branches, $branch; |
|
144 | 96 |
} |
97 |
+ $all_count++; |
|
145 | 98 |
} |
146 | 99 |
|
147 | 100 |
my $original_project_row_id = app->dbi->model('project')->select( |
... | ... |
@@ -171,51 +124,9 @@ |
171 | 124 |
|
172 | 125 |
<!-- Branches (for tests) --> |
173 | 126 |
|
174 |
- <ul class="branches-select"> |
|
175 |
- <li class="<%= $display eq 'overview' ? 'active' : '' %>"> |
|
176 |
- <a href="<%= url_for("/$user_id/$project_id/branches") %>">Overview</a> |
|
177 |
- </li> |
|
178 |
- <li class="<%= $display eq 'active' ? 'active' : '' %>"> |
|
179 |
- <a href="<%= url_for("/$user_id/$project_id/branches/active") %>">Active</a> |
|
180 |
- </li> |
|
181 |
- <li class="<%= $display eq 'stale' ? 'active' : '' %>"> |
|
182 |
- <a href="<%= url_for("/$user_id/$project_id/branches/stale") %>">Stale</a> |
|
183 |
- </li> |
|
184 |
- <li class="<%= $display eq 'all' ? 'active' : '' %>"> |
|
185 |
- <a href="<%= url_for("/$user_id/$project_id/branches/all") %>">All branches</a> |
|
186 |
- </li> |
|
187 |
- </ul> |
|
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 |
- %> |
|
202 |
- |
|
203 |
- % for my $branch_type (@$branch_types) { |
|
204 |
- % my $branches = $branches_h->{$branch_type}; |
|
205 |
- |
|
206 |
- % if (@$branches || $display ne 'overview') { |
|
127 |
+ <h1 class="topic1">Branches</h1> |
|
128 |
+ % if (@$branches) { |
|
207 | 129 |
<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> |
|
219 | 130 |
% if (@$branches) { |
220 | 131 |
% my $branches_count; |
221 | 132 |
% for (my $i = 0; $i < @$branches; $i++) { |
... | ... |
@@ -247,175 +158,158 @@ |
247 | 158 |
} |
248 | 159 |
|
249 | 160 |
%> |
250 |
- % if ($display eq 'overview' && $i > 4) { |
|
251 |
- <li class="branches-overview-more"> |
|
252 |
- <a href="<%= url_for("/$user_id/$project_id/branches/$branch_type") %>"> |
|
253 |
- View more <%= $branch_type %> branches |
|
254 |
- </a> |
|
255 |
- </li> |
|
256 |
- % last; |
|
257 |
- % } else { |
|
258 | 161 |
|
259 |
- <li> |
|
260 |
- <ul> |
|
261 |
- <li> |
|
262 |
- <div class="branches-name"> |
|
263 |
- <a href="<%= url_for("/$user_id/$project_id/tree/$branch_name") %>"> |
|
264 |
- <%= $branch_name %> |
|
265 |
- </a> |
|
266 |
- </div> |
|
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} %>"> |
|
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 |
- % } |
|
276 |
- </div> |
|
277 |
- </li> |
|
278 |
- <li class="second-child"> |
|
279 |
- % if ($branch_name eq $default_branch_name) { |
|
280 |
- <div style="padding-left:80px;padding-top:3px"> |
|
281 |
- <div class="branches-default"> |
|
282 |
- Default |
|
283 |
- </div> |
|
284 |
- </div> |
|
162 |
+ <li> |
|
163 |
+ <ul> |
|
164 |
+ <li> |
|
165 |
+ <div class="branches-name"> |
|
166 |
+ <a href="<%= url_for("/$user_id/$project_id/tree/$branch_name") %>"> |
|
167 |
+ <%= $branch_name %> |
|
168 |
+ </a> |
|
169 |
+ </div> |
|
170 |
+ <div class="branches-age" title="<%= $branch->{commit}{age_string_datetime_local} %>"> |
|
171 |
+ Updated <%= $branch->{commit}{age_string} %> by |
|
172 |
+ </div> |
|
173 |
+ <div class="branches-author" title="<%= $branch->{commit}{author_email} %>"> |
|
174 |
+ % if (defined $commit_author_id) { |
|
175 |
+ <a href="<%= url_for("/$commit_author_id") %>"><%= $commit_author_id %></a> |
|
285 | 176 |
% } 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"> |
|
299 |
- <div style="margin-left:auto;margin-right:0;background:#dcdcdc;width:<%= $branch->{status}{behind_bar} %>%;height:4px"></div> |
|
300 |
- </td> |
|
301 |
- <td class="ahead-behind-separate"> |
|
302 |
- </td> |
|
303 |
- <td style="width:100px"> |
|
304 |
- <div style="background:#dcdcdc;width:<%= $branch->{status}{ahead_bar} %>%;height:4px"></div> |
|
305 |
- </td> |
|
306 |
- </tr> |
|
307 |
- </table> |
|
177 |
+ <%= $branch->{commit}{author_name} %> |
|
308 | 178 |
% } |
309 |
- </li> |
|
310 |
- <li class="last-child"> |
|
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> |
|
314 |
- % } |
|
315 |
- % } else { |
|
316 |
- % if ($api->logined) { |
|
317 |
- % if ($pull_request) { |
|
318 |
- #<%= $issue->{number} %> |
|
319 |
- % if ($issue->{open}) { |
|
320 |
- <a class="branches-open" href="<%= url_for("/$user/$project/pull/$issue->{number}") %>"> |
|
321 |
- open |
|
322 |
- </a> |
|
323 |
- % } else { |
|
324 |
- <a class="branches-close" href="<%= url_for("/$user/$project/pull/$issue->{number}") %>"> |
|
325 |
- closed |
|
326 |
- </a> |
|
327 |
- % } |
|
179 |
+ </div> |
|
180 |
+ </li> |
|
181 |
+ <li class="second-child"> |
|
182 |
+ % if ($branch_name eq $default_branch_name) { |
|
183 |
+ <div style="padding-left:80px;padding-top:3px"> |
|
184 |
+ <div class="branches-default"> |
|
185 |
+ Default |
|
186 |
+ </div> |
|
187 |
+ </div> |
|
188 |
+ % } else { |
|
189 |
+ <table class="ahead-behind"> |
|
190 |
+ <tr> |
|
191 |
+ <td class="ahead-behind-behind-count"> |
|
192 |
+ <%= $branch->{status}{behind} %> |
|
193 |
+ </td> |
|
194 |
+ <td class="ahead-behind-separate"> |
|
195 |
+ </td> |
|
196 |
+ <td style="padding-left:3px"> |
|
197 |
+ <%= $branch->{status}{ahead} %> |
|
198 |
+ </td> |
|
199 |
+ </tr> |
|
200 |
+ <tr> |
|
201 |
+ <td style="width:100px"> |
|
202 |
+ <div style="margin-left:auto;margin-right:0;background:#dcdcdc;width:<%= $branch->{status}{behind_bar} %>%;height:4px"></div> |
|
203 |
+ </td> |
|
204 |
+ <td class="ahead-behind-separate"> |
|
205 |
+ </td> |
|
206 |
+ <td style="width:100px"> |
|
207 |
+ <div style="background:#dcdcdc;width:<%= $branch->{status}{ahead_bar} %>%;height:4px"></div> |
|
208 |
+ </td> |
|
209 |
+ </tr> |
|
210 |
+ </table> |
|
211 |
+ % } |
|
212 |
+ </li> |
|
213 |
+ <li class="last-child"> |
|
214 |
+ % if ($branch_name eq $default_branch_name) { |
|
215 |
+ % if ($api->logined($user_id)) { |
|
216 |
+ <a href="<%= url_for("/$user_id/$project_id/settings#form-default-branch") %>" type="submit" class="btn btn-small">Change default branch</a> |
|
217 |
+ % } |
|
218 |
+ % } else { |
|
219 |
+ % if ($api->logined) { |
|
220 |
+ % if ($pull_request) { |
|
221 |
+ #<%= $issue->{number} %> |
|
222 |
+ % if ($issue->{open}) { |
|
223 |
+ <a class="branches-open" href="<%= url_for("/$user/$project/pull/$issue->{number}") %>"> |
|
224 |
+ open |
|
225 |
+ </a> |
|
328 | 226 |
% } else { |
329 |
- <% |
|
330 |
- my $compare_url; |
|
331 |
- if ($original_project) { |
|
332 |
- my $original_user_id = $original_project->{'user.id'}; |
|
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 %>"> |
|
352 |
- New pull request |
|
227 |
+ <a class="branches-close" href="<%= url_for("/$user/$project/pull/$issue->{number}") %>"> |
|
228 |
+ closed |
|
353 | 229 |
</a> |
354 | 230 |
% } |
355 | 231 |
% } else { |
356 |
- <a class="btn btn-small" href="<%= url_for("/$user_id/$project_id/compare/$branch_name")->query(expand => 1) %>"> |
|
357 |
- Compare |
|
232 |
+ <% |
|
233 |
+ my $compare_url; |
|
234 |
+ if ($original_project) { |
|
235 |
+ my $original_user_id = $original_project->{'user.id'}; |
|
236 |
+ my $original_project_id = $original_project->{id}; |
|
237 |
+ |
|
238 |
+ my $exists_original_branch_name = app->git->exists_branch( |
|
239 |
+ app->rep_info($original_user_id, $original_project_id), |
|
240 |
+ $branch_name |
|
241 |
+ ); |
|
242 |
+ if ($exists_original_branch_name) { |
|
243 |
+ $compare_url = url_for("/$original_user_id/$original_project_id/compare/$branch_name...$user_id:$branch_name")->query(expand => 1); |
|
244 |
+ } |
|
245 |
+ else { |
|
246 |
+ my $original_project_default_branch = app->manager->default_branch($original_user_id, $original_project_id); |
|
247 |
+ $compare_url = url_for("/$original_user_id/$original_project_id/compare/$original_project_default_branch...$user_id:$branch_name")->query(expand => 1); |
|
248 |
+ } |
|
249 |
+ } |
|
250 |
+ else { |
|
251 |
+ $compare_url = url_for("/$user_id/$project_id/compare/$branch_name")->query(expand => 1); |
|
252 |
+ } |
|
253 |
+ %> |
|
254 |
+ <a class="btn btn-small" href="<%= $compare_url %>"> |
|
255 |
+ New pull request |
|
358 | 256 |
</a> |
359 | 257 |
% } |
360 |
- % if ($api->logined($user_id)) { |
|
361 |
- % if ($pull_request && $issue->{open}) { |
|
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> |
|
368 |
- % } |
|
258 |
+ % } else { |
|
259 |
+ <a class="btn btn-small" href="<%= url_for("/$user_id/$project_id/compare/$branch_name")->query(expand => 1) %>"> |
|
260 |
+ Compare |
|
261 |
+ </a> |
|
262 |
+ % } |
|
263 |
+ % if ($api->logined($user_id)) { |
|
264 |
+ % if ($pull_request && $issue->{open}) { |
|
265 |
+ <button class="btn btn-small disabled delete-branch"value="Delete">Delete</button> |
|
266 |
+ % } else { |
|
267 |
+ <form action="<%= url_for->query(op => 'delete') %>" method="post" style="display:inline-block"> |
|
268 |
+ <input type="submit" class="btn btn-small delete-branch" style="color:#900;" value="Delete"> |
|
269 |
+ %= hidden_field branch => $branch_name; |
|
270 |
+ </form> |
|
369 | 271 |
% } |
370 | 272 |
% } |
371 |
- </li> |
|
372 |
- </ul> |
|
373 |
- </li> |
|
374 |
- % } |
|
273 |
+ % } |
|
274 |
+ </li> |
|
275 |
+ </ul> |
|
276 |
+ </li> |
|
375 | 277 |
% $branches_count++; |
376 | 278 |
% } |
377 | 279 |
|
378 | 280 |
|
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> |
|
387 |
- <a href="<%= url_for("/$user_id/$project_id/branches/$display?page=$newer_page") %>">Newer</a> |
|
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> |
|
395 |
- <a href="<%= url_for("/$user_id/$project_id/branches/$display?page=$older_page") %>">Older</a> |
|
396 |
- </li> |
|
397 |
- % } |
|
398 |
- </ul> |
|
399 |
- </div> |
|
400 |
- % } |
|
281 |
+ <div class="pagenation-container" style="margin-top:20px"> |
|
282 |
+ <ul class="pagenation"> |
|
283 |
+ % if ($page == 1) { |
|
284 |
+ <li><span>Newer</span></li> |
|
285 |
+ % } else { |
|
286 |
+ % my $newer_page = $page - 1; |
|
287 |
+ <li> |
|
288 |
+ <a href="<%= url_for("/$user_id/$project_id/branches/$display?page=$newer_page") %>">Newer</a> |
|
289 |
+ </li> |
|
290 |
+ % } |
|
291 |
+ % if ($branches_count < $page_count) { |
|
292 |
+ <li><span>Older</span></li> |
|
293 |
+ % } else { |
|
294 |
+ % my $older_page = $page + 1; |
|
295 |
+ <li> |
|
296 |
+ <a href="<%= url_for("/$user_id/$project_id/branches/$display?page=$older_page") %>">Older</a> |
|
297 |
+ </li> |
|
298 |
+ % } |
|
299 |
+ </ul> |
|
300 |
+ </div> |
|
401 | 301 |
% } else { |
402 | 302 |
<li style="text-align:center;text-color:#767676"> |
403 | 303 |
<% |
404 | 304 |
my $branch_type_name; |
405 |
- if ($branch_type eq 'active' || $branch_type eq 'stale') { |
|
406 |
- $branch_type_name = $branch_type; |
|
407 |
- } |
|
408 |
- else { |
|
409 | 305 |
$branch_type_name = ''; |
410 |
- } |
|
411 | 306 |
%> |
412 | 307 |
|
413 |
- There aren’t any <%= $branch_type_name %> branches. |
|
308 |
+ There aren’t any branches. |
|
414 | 309 |
</li> |
415 | 310 |
% } |
416 | 311 |
</ul> |
417 | 312 |
% } |
418 |
- % } |
|
419 | 313 |
</div> |
420 | 314 |
|
421 | 315 |
%= include '/include/footer'; |