... | ... |
@@ -1,83 +1,94 @@ |
1 | 1 |
<% |
2 | 2 |
my $rev = stash('rev'); |
3 | 3 |
my $from_rev = stash('from_rev'); |
4 |
- my $status = stash('status') || ''; |
|
5 | 4 |
my $diff_tree = stash('diff_tree'); |
5 |
+ my $blob_diff = stash('blob_diff'); |
|
6 |
+ my $lines = $blob_diff->{lines}; |
|
7 |
+ my $file = $blob_diff->{file}; |
|
8 |
+ my $from_file = $blob_diff->{from_file}; |
|
9 |
+ $from_file = $file unless defined $from_file; |
|
10 |
+ my $status = $blob_diff->{status}; |
|
6 | 11 |
%> |
7 | 12 |
|
8 |
-<div style="margin-bottom:20px;"> |
|
9 |
- <div class="border-gray bk-gray-light" style="padding:5px"> |
|
10 |
- <div class="row"> |
|
11 |
- <div class="span8" style="padding-top:3px"> |
|
12 |
- <div class="radius-top radius-bottom" style="padding:1px 3px;margin-right:5px;border:1px solid #ccc;display:inline-block;background:#f7f7f7"> |
|
13 |
- %= include '/include/diff_status_bar', diff_tree => $diff_tree; |
|
13 |
+ <div style="margin-bottom:20px;"> |
|
14 |
+ <div class="border-gray bk-gray-light" style="padding:5px"> |
|
15 |
+ <div class="row"> |
|
16 |
+ <div class="span8" style="padding-top:3px"> |
|
17 |
+ <div class="radius-top radius-bottom" style="padding:1px 3px;margin-right:5px;border:1px solid #ccc;display:inline-block;background:#f7f7f7"> |
|
18 |
+ %= include '/include/diff_status_bar', diff_tree => $diff_tree; |
|
19 |
+ </div> |
|
20 |
+ <%= $file %> |
|
14 | 21 |
</div> |
15 |
- <%= $file %> |
|
16 |
- </div> |
|
17 |
- <div class="text-right"> |
|
18 |
- % if ($status eq 'D') { |
|
19 |
- <a class="btn" href="<%= url_for("/$user/$project/blob/$from_rev/$file") %>"> |
|
20 |
- View file @ <%= substr($from_rev, 0, 7) %> |
|
21 |
- </a> |
|
22 |
- % } else { |
|
23 |
- <a class="btn" href="<%= url_for("/$user/$project/blob/$rev/$file") %>"> |
|
24 |
- View file @ <%= substr($rev, 0, 7) %> |
|
25 |
- </a> |
|
26 |
- % } |
|
27 |
- </div> |
|
28 |
- </div> |
|
29 |
- </div> |
|
30 |
- <table class="border-gray" style="border-top:none"> |
|
31 |
- % for my $line (@$lines) { |
|
32 |
- % my $class = $line->{class}; |
|
33 |
- % my $value = $line->{value}; |
|
34 |
- % if ($class eq 'binary_file') { |
|
35 |
- <div class="border-gray" style="border-top:none;background:#ddd;text-align:center;padding-top:30px;padding-bottom:30px"> |
|
36 |
- % if ($status ne 'A') { |
|
37 |
- <a href="<%= url_for("/$user/$project/blob/$from_rev/$file") %>"> |
|
38 |
- <img src="<%= url_for("/$user/$project/raw/$from_rev/$file") %>" style="border:1px solid red;padding:1px;margin-right:20px"> |
|
22 |
+ <div class="text-right"> |
|
23 |
+ % if ($status eq 'D') { |
|
24 |
+ <a class="btn" href="<%= url_for("/$user/$project/blob/$from_rev/$file") %>"> |
|
25 |
+ View file @ <%= substr($from_rev, 0, 7) %> |
|
39 | 26 |
</a> |
40 |
- % } |
|
41 |
- % if ($status ne 'D') { |
|
42 |
- <a href="<%= url_for("/$user/$project/blob/$rev/$file") %>"> |
|
43 |
- <img src="<%= url_for("/$user/$project/raw/$rev/$file") %>" style="border:1px solid green;padding:1px;margin-left:20px"> |
|
27 |
+ % } else { |
|
28 |
+ <a class="btn" href="<%= url_for("/$user/$project/blob/$rev/$file") %>"> |
|
29 |
+ View file @ <%= substr($rev, 0, 7) %> |
|
44 | 30 |
</a> |
45 | 31 |
% } |
46 | 32 |
</div> |
47 |
- % last; |
|
33 |
+ </div> |
|
34 |
+ </div> |
|
35 |
+ <table class="border-gray" style="border-top:none"> |
|
36 |
+ % if ($lines) { |
|
37 |
+ % for my $line (@$lines) { |
|
38 |
+ % my $class = $line->{class}; |
|
39 |
+ % my $value = $line->{value}; |
|
40 |
+ % if ($class eq 'binary_file') { |
|
41 |
+ <div class="border-gray" style="border-top:none;background:#ddd;text-align:center;padding-top:30px;padding-bottom:30px"> |
|
42 |
+ % if ($status ne 'A') { |
|
43 |
+ <a href="<%= url_for("/$user/$project/blob/$from_rev/$file") %>"> |
|
44 |
+ <img src="<%= url_for("/$user/$project/raw/$from_rev/$file") %>" style="border:1px solid red;padding:1px;margin-right:20px"> |
|
45 |
+ </a> |
|
46 |
+ % } |
|
47 |
+ % if ($status ne 'D') { |
|
48 |
+ <a href="<%= url_for("/$user/$project/blob/$rev/$file") %>"> |
|
49 |
+ <img src="<%= url_for("/$user/$project/raw/$rev/$file") %>" style="border:1px solid green;padding:1px;margin-left:20px"> |
|
50 |
+ </a> |
|
51 |
+ % } |
|
52 |
+ </div> |
|
53 |
+ % last; |
|
54 |
+ % } else { |
|
55 |
+ <% |
|
56 |
+ my $bk_color_line = ''; |
|
57 |
+ my $bk_color = ''; |
|
58 |
+ my $border_color; |
|
59 |
+ if ($value =~ /^@/) { |
|
60 |
+ $bk_color_line = '#f3f3ff'; |
|
61 |
+ $border_color = '#e4e4ff'; |
|
62 |
+ $bk_color = '#f8f8ff'; |
|
63 |
+ } elsif ($value =~ /^\+/) { |
|
64 |
+ $bk_color_line = '#ceffce'; |
|
65 |
+ $border_color = '#b4e2b4'; |
|
66 |
+ $bk_color = '#dfd'; |
|
67 |
+ } elsif ($value =~ /^-/) { |
|
68 |
+ $bk_color_line = '#f7c8c8'; |
|
69 |
+ $border_color = '#e9aeae'; |
|
70 |
+ $bk_color = '#fdd'; |
|
71 |
+ } else { |
|
72 |
+ $border_color = '#e5e5e5'; |
|
73 |
+ } |
|
74 |
+ %> |
|
75 |
+ <tr > |
|
76 |
+ <td style="font-size:12px;color:#aaa;padding:0 7px;border-right:1px <%= $border_color %> solid;background:<%= $bk_color_line %>;"> |
|
77 |
+ <%= $line->{before_line_num} %> |
|
78 |
+ </td> |
|
79 |
+ <td style="font-size:12px;color:#aaa;padding:0 7px;border-right:1px <%= $border_color %> solid;background:<%= $bk_color_line %>;"> |
|
80 |
+ <%= $line->{after_line_num} %> |
|
81 |
+ </td> |
|
82 |
+ <td style="width:100%;padding-left:7px;background:<%= $bk_color %>;"> |
|
83 |
+ <pre style="border:none;background:none;padding:0;margin:0"><%= $value %></pre> |
|
84 |
+ </td> |
|
85 |
+ </tr> |
|
86 |
+ % } |
|
87 |
+ % } |
|
48 | 88 |
% } else { |
49 |
- <% |
|
50 |
- my $bk_color_line = ''; |
|
51 |
- my $bk_color = ''; |
|
52 |
- my $border_color; |
|
53 |
- if ($value =~ /^@/) { |
|
54 |
- $bk_color_line = '#f3f3ff'; |
|
55 |
- $border_color = '#e4e4ff'; |
|
56 |
- $bk_color = '#f8f8ff'; |
|
57 |
- } elsif ($value =~ /^\+/) { |
|
58 |
- $bk_color_line = '#ceffce'; |
|
59 |
- $border_color = '#b4e2b4'; |
|
60 |
- $bk_color = '#dfd'; |
|
61 |
- } elsif ($value =~ /^-/) { |
|
62 |
- $bk_color_line = '#f7c8c8'; |
|
63 |
- $border_color = '#e9aeae'; |
|
64 |
- $bk_color = '#fdd'; |
|
65 |
- } else { |
|
66 |
- $border_color = '#e5e5e5'; |
|
67 |
- } |
|
68 |
- %> |
|
69 |
- <tr > |
|
70 |
- <td style="font-size:12px;color:#aaa;padding:0 7px;border-right:1px <%= $border_color %> solid;background:<%= $bk_color_line %>;"> |
|
71 |
- <%= $line->{before_line_num} %> |
|
72 |
- </td> |
|
73 |
- <td style="font-size:12px;color:#aaa;padding:0 7px;border-right:1px <%= $border_color %> solid;background:<%= $bk_color_line %>;"> |
|
74 |
- <%= $line->{after_line_num} %> |
|
75 |
- </td> |
|
76 |
- <td style="width:100%;padding-left:7px;background:<%= $bk_color %>;"> |
|
77 |
- <pre style="border:none;background:none;padding:0;margin:0"><%= $value %></pre> |
|
78 |
- </td> |
|
79 |
- </tr> |
|
89 |
+ <div class="border-gray" style="padding:10px;margin-bottom:30px;border-top:none"> |
|
90 |
+ No changes. |
|
91 |
+ </div> |
|
80 | 92 |
% } |
81 |
- % } |
|
82 |
- </table> |
|
83 |
-</div> |
|
93 |
+ </table> |
|
94 |
+ </div> |
... | ... |
@@ -58,18 +58,10 @@ |
58 | 58 |
<div class="row" style="margin-bottom:10px"> |
59 | 59 |
<div class="span8" style="padding-top:5px"> |
60 | 60 |
Showing <b><%= @$diff_trees %> changed files</b> |
61 |
- % if ($total_add_line_count || $total_delete_line_count) { |
|
62 |
- with |
|
63 |
- % } |
|
64 |
- % if ($total_add_line_count) { |
|
65 |
- <b><%= $total_add_line_count %> additions</b> |
|
66 |
- % } |
|
67 |
- % if ($total_add_line_count && $total_delete_line_count) { |
|
68 |
- and |
|
69 |
- % } |
|
70 |
- % if ($total_delete_line_count) { |
|
71 |
- <b><%= $total_delete_line_count %> deletions</b> |
|
72 |
- % } |
|
61 |
+ with |
|
62 |
+ <b><%= $total_add_line_count %> additions</b> |
|
63 |
+ and |
|
64 |
+ <b><%= $total_delete_line_count %> deletions</b> |
|
73 | 65 |
</div> |
74 | 66 |
<div class="text-right"> |
75 | 67 |
<button id="diff-stats-btn" class="btn">Show Diff Stats</button> |
... | ... |
@@ -83,21 +75,8 @@ |
83 | 75 |
% for my $file (sort keys %$diff_trees_h) { |
84 | 76 |
<div id="diff-<%= $num %>"> |
85 | 77 |
% my $blob_diff = $blob_diffs_h->{$file}; |
86 |
- % if ($blob_diff) { |
|
87 |
- % my $lines = $blob_diff->{lines}; |
|
88 |
- % my $file = $blob_diff->{file}; |
|
89 |
- % my $from_file = $blob_diff->{from_file}; |
|
90 |
- % $from_file = $file unless defined $from_file; |
|
91 |
- % my $status = $blob_diff->{status}; |
|
92 |
- %= include '/include/blob_diff_body', diff_tree => $diff_trees_h->{$file}, file => $file, from_file => $from_file, status => $status, lines => $blob_diff->{lines}; |
|
93 |
- % } else { |
|
94 |
- <div class="border-gray bk-gray-light" style="border-bottom:none;padding:10px"> |
|
95 |
- <%= $file %> |
|
96 |
- </div> |
|
97 |
- <div class="border-gray" style="padding:10px;margin-bottom:30px"> |
|
98 |
- No changes. Empty file is added. |
|
99 |
- </div> |
|
100 |
- % } |
|
78 |
+ % $blob_diff ||= {status => 'A', file => $file}; |
|
79 |
+ %= include '/include/blob_diff_body', blob_diff => $blob_diff, diff_tree => $diff_trees_h->{$file}; |
|
101 | 80 |
</div> |
102 | 81 |
% $num++; |
103 | 82 |
% } |
... | ... |
@@ -4,8 +4,14 @@ |
4 | 4 |
my $add_line_count = $diff_tree->{add_line_count} || 0; |
5 | 5 |
my $delete_line_count = $diff_tree->{delete_line_count} || 0; |
6 | 6 |
my $diff_line_count = $add_line_count + $delete_line_count; |
7 |
- my $diff_count_text = "$add_line_count additions"; |
|
8 |
- $diff_count_text .= " & $delete_line_count deletions" if $delete_line_count > 0; |
|
7 |
+ my $diff_count_text; |
|
8 |
+ if ($diff_tree->{status} eq 'A' && $add_line_count == 0) { |
|
9 |
+ $diff_count_text = 'Empty file added'; |
|
10 |
+ } |
|
11 |
+ else { |
|
12 |
+ $diff_count_text = "$add_line_count additions"; |
|
13 |
+ $diff_count_text .= " & $delete_line_count deletions" if $delete_line_count > 0; |
|
14 |
+ } |
|
9 | 15 |
my $tag = $fragment ? 'a' : 'span'; |
10 | 16 |
my $add_block_count = $diff_tree->{add_block_count} || 0; |
11 | 17 |
my $delete_block_count = $diff_tree->{delete_block_count} || 0; |