1 contributor
<%
my $parents = stash('parents') || [];
%>
%= stylesheet begin
.file-add {
color:#32CD32;
border:2px #32CD32 solid;
margin-left:3px;
font-weight:bold;
line-height:0;
display:table-cell;
text-align:center;
vertical-align:middle;
width:9px;
height:9px;
font-size:13px;
}
.file-del {
color:red;
border:2px red solid;
margin-left:3px;
font-weight:bold;
line-height:0;
display:table-cell;
text-align:center;
vertical-align:middle;
width:9px;
height:9px;
font-size:15px;
}
.file-modified {
color:#DAA520;
border:2px #DAA520 solid;
margin-left:3px;
font-weight:bold;
line-height:0;
display:table-cell;
text-align:center;
vertical-align:middle;
width:9px;
height:9px;
font-size:11px;
}
% end
<table style="margin-bottom:10px;width:100%">
% my $has_header = @$diff_trees && @$parents > 1 && stash('action') eq 'commitdiff';
% if ($has_header) {
<tr>
<th></th>
% for (my $i = 0; $i < @$parents; $i++) {
% my $parent = $parents->[$i];
% my $from_id = $parent;
<th>
<a href="<%= url_for("/$user/$project/commit/$from_id..$id") %>"
title="commitdiff to parent number <%= $i + 1 %> <%= substr($from_id, 0, 7) %>">
<%= $i + 1 %>
</a>
</th>
% }
</tr>
% }
% my $toggle = 0;
% my $num = 0;
% for my $diff_tree (@$diff_trees) {
<tr style="<%= $num + 1 ne @$diff_trees ? 'border-bottom:1px #ddd solid' : '' %>">
% if (exists $diff_tree->{'nparents'}) {
% my $file = $diff_tree->{to_file};
% if ($diff_tree->{is_deleted}) {
<td>
<%= $file %>
</td>
% } else {
<td>
<a href="<%= url_for("/$user/$project/blob/$id/$file") %>">
<%= $file %>
</a>
</td>
% }
% my $not_deleted = 0;
% for (my $i = 0; $i < $diff_tree->{'nparents'}; $i++) {
% my $from_id = $parents->[$i];
% my $from_bid = $diff_tree->{'from_id'}[$i];
% my $from_file = $diff_tree->{'from_file'}[$i];
% $from_file = $file unless defined $from_file;
% my $status = $diff_tree->{'status'}[$i];
% $not_deleted ||= ($status ne 'D');
% if ($status eq 'A') {
<td> | </td>
% } elsif ($status eq 'D') {
<td>
<a href="#">
blob<%= $i + 1 %>
</a>
|
</td>
% } else {
% if ($diff_tree->{'to_id'} eq $from_bid) {
<td>
% } else {
<td>
% }
<a href="#">
diff<%= $i + 1 %>
</a>
| </td>
% }
% }
<td>
% if ($not_deleted) {
% my $from_file = $diff_tree->{from_file};
<a href="#">
blob
</a>
% }
</td>
% } else {
% my $status = $diff_tree->{status};
% my $file = $diff_tree->{to_file};
% my $file_type = $diff_tree->{to_file_type};
% my $mode = $diff_tree->{to_mode};
% my $mode_str = $diff_tree->{to_mode_str};
% my $mode_oct = $diff_tree->{to_mode_oct};
% my $from_file = $diff_tree->{from_file};
% my $from_file_type = $diff_tree->{from_file_type};
% my $from_mode = $diff_tree->{from_mode};
% my $from_mode_str = $diff_tree->{from_mode_str};
% my $from_mode_oct = $diff_tree->{from_mode_oct};
<td style="padding:7px 0; width:12px">
% if ($status eq 'A') {
<div class="file-add">+</div>
% } elsif ($status eq 'D') {
<div class="file-del">-</div>
% } elsif ($status eq 'M' || $status eq 'T') {
<div class="file-modified">●</div>
% if ($from_mode != $mode) {
<span>
[
changed
% if ($from_file_type ne $file_type) {
from <%= $from_file_type %> to <%= $file_type %>
% }
% if (($from_mode_oct & 0777) != ($mode_oct & 0777)) {
% if ($from_mode_str && $mode_str) {
mode: <%= $from_mode_str %>-><%= $mode_str %>
% } elsif ($mode_str) {
mode: <%= $mode_str %>
% }
% }
]
</span>
% }
% } elsif ($status eq 'R' || $status eq 'C') {
% my $status_name = $status eq 'R' ? 'moved' : 'copied';
% my $mode_change = "";
% if ($diff_tree->{'from_mode'} != $diff_tree->{'to_mode'}) {
% $mode_change = sprintf(", mode: %04o", oct $diff_tree->{to_mode} & 0777);
% }
<span>
[
<%= $status_name %> from
<a href="#"><%= $diff_tree->{from_file} %></a>
with <%= $diff_tree->{similarity} %>%
<%= $mode_change %>
]
</span>
% }
</td>
<td>
<a style="margin-left:5px" href="#<%= "diff-$num" %>"><%= $file %></a>
</td>
<td style="text-align:right">
%= include '/include/diff_status_bar', diff_tree => $diff_tree, fragment => "diff-$num";
</td>
% }
</tr>
% $num++;
% }
</table>