add diff status bar to commi...
|
1 |
<% |
2 |
# Parameters |
|
cleanup commit_body logic
|
3 |
my $user_id = stash('user'); |
4 |
my $project_id = stash('project'); |
|
5 |
my $rep_info = stash('rep_info') // app->rep_info($user_id, $project_id); |
|
cleanup
|
6 |
my $rev = stash('rev'); |
7 |
my $from_rev = stash('from_rev'); |
|
add --ignore-space-change fe...
|
8 | |
9 |
my $param_ignore_space_change = param('w'); |
|
remove [basic]show_ignore_sp...
|
10 |
my $ignore_space_change; |
11 |
if ($param_ignore_space_change) { |
|
12 |
$ignore_space_change = 1; |
|
13 |
} |
|
14 |
else { |
|
15 |
$ignore_space_change = app->dbi->model('project')->select( |
|
16 |
'ignore_space_change', |
|
cleanup commit_body logic
|
17 |
where => {user_id => $user_id, name => $project_id} |
remove [basic]show_ignore_sp...
|
18 |
)->value; |
19 |
} |
|
add diff status bar to commi...
|
20 |
|
21 |
# Git |
|
revert encoding support
|
22 |
my $git = app->git; |
add diff status bar to commi...
|
23 |
|
24 |
# Diff tree |
|
25 |
my $diff_trees = $git->diff_tree( |
|
fix compare page from forke...
|
26 |
$rep_info, |
cleanup
|
27 |
$rev, |
28 |
$from_rev, |
|
add --ignore-space-change fe...
|
29 |
{ignore_space_change => $ignore_space_change} |
add diff status bar to commi...
|
30 |
); |
improve rename commit
|
31 | |
add diff status bar to commi...
|
32 |
my $diff_trees_h = {}; |
33 |
for my $diff_tree (@$diff_trees) { |
|
improve rename commit
|
34 |
my $file = $diff_tree->{to_file}; |
35 |
$file = $diff_tree->{from_file} unless defined $file; |
|
add diff status bar to commi...
|
36 |
$diff_trees_h->{$file} = $diff_tree if defined $file; |
37 |
} |
|
38 |
|
|
39 |
# Get blob diffs |
|
add --ignore-space-change fe...
|
40 |
my $blob_diffs = $git->blob_diffs( |
fix compare page from forke...
|
41 |
$rep_info, |
cleanup rep_info
|
42 |
$from_rev, |
43 |
$rev, |
|
44 |
$diff_trees, |
|
45 |
{ignore_space_change => $ignore_space_change} |
|
add --ignore-space-change fe...
|
46 |
) || []; |
47 |
|
|
add diff status bar to commi...
|
48 |
my $blob_diffs_h = {}; |
add total add and delete lin...
|
49 |
my $total_add_line_count = 0; |
50 |
my $total_delete_line_count = 0; |
|
add diff status bar to commi...
|
51 |
for my $blob_diff (@$blob_diffs) { |
52 |
my $file = $blob_diff->{file}; |
|
53 |
$blob_diffs_h->{$file} = $blob_diff; |
|
add total add and delete lin...
|
54 |
$total_add_line_count += $blob_diff->{add_line_count}; |
55 |
$total_delete_line_count += $blob_diff->{delete_line_count}; |
|
add diff status bar to commi...
|
56 |
} |
fix compare and pull page vi...
|
57 |
|
58 |
# diff_tree arguments |
|
59 |
my %diff_tree_args = ( |
|
60 |
rev => $rev, |
|
61 |
from_rev => $from_rev, |
|
62 |
diff_trees => $diff_trees |
|
63 |
); |
|
64 |
|
|
add diff status bar to commi...
|
65 |
%> |
66 | ||
67 |
%= javascript begin |
|
68 |
$(document).ready(function () { |
|
69 |
|
|
70 |
// Diff Stats Button |
|
71 |
var diff_tree_show = false; |
|
72 |
var original_diff_stats_btn_text = $('#diff-stats-btn').text(); |
|
73 |
|
|
74 |
$('#diff-stats-btn').on('click', function () { |
|
75 |
if (diff_tree_show) { |
|
76 |
$(this).text(original_diff_stats_btn_text); |
|
77 |
$('#diff_tree').css('display', 'none'); |
|
78 |
} |
|
79 |
else { |
|
80 |
$('#diff_tree').css('display', 'block'); |
|
81 |
} |
|
82 |
diff_tree_show = !diff_tree_show; |
|
83 |
}); |
|
84 |
}); |
|
85 |
% end |
|
86 | ||
improve commit page design
|
87 |
<div class="commit-changes"> |
88 |
<div> |
|
89 |
Showing <b><a id="diff-stats-btn" href="javascript:void;"><%= @$diff_trees %> changed files</a></b> |
|
improve first commit
|
90 |
with |
91 |
<b><%= $total_add_line_count %> additions</b> |
|
92 |
and |
|
93 |
<b><%= $total_delete_line_count %> deletions</b> |
|
add diff status bar to commi...
|
94 |
</div> |
95 |
</div> |
|
improve commit page design
|
96 | |
97 |
<div id="diff_tree" style="display:none"> |
|
fix compare and pull page vi...
|
98 |
%= include '/include/diff_tree', %diff_tree_args; |
add diff status bar to commi...
|
99 |
</div> |
improve commit page design
|
100 | |
add diff status bar to commi...
|
101 |
% my $num = 0; |
102 |
% for my $file (sort keys %$diff_trees_h) { |
|
fix compare and pull page vi...
|
103 |
<% |
104 |
# blob_diff_body arguments |
|
105 |
my $blob_diff = $blob_diffs_h->{$file}; |
|
106 |
my %blob_diff_body_args = ( |
|
107 |
user => $user_id, |
|
108 |
project => $project_id, |
|
109 |
blob_diff => $blob_diff, |
|
110 |
diff_tree => $diff_trees_h->{$file} |
|
111 |
); |
|
112 |
%> |
|
add diff status bar to commi...
|
113 |
<div id="diff-<%= $num %>"> |
fix compare and pull page vi...
|
114 |
%= include '/include/blob_diff_body', %blob_diff_body_args; |
add diff status bar to commi...
|
115 |
</div> |
116 |
% $num++; |
|
117 |
% } |
|
118 |
</div> |