1 contributor
<%
# API
my $api = gitprep_api;
# Paramters
my $project = param('project');
my $diff = param('diff');
my ($from_id, $id) = $diff =~ /(.+)\.\.(.+)/;
$id = $diff unless defined $id;
# Git
my $git = app->git;
# Commit
my $commit = $git->get_commit($user, $project, $id);
unless ($commit) {
$self->render_not_found;
$self->finish_rendering;
return;
}
my $author_date
= $git->parse_date($commit->{author_epoch}, $commit->{author_tz});
my $committer_date
= $git->parse_date($commit->{committer_epoch}, $commit->{committer_tz});
$commit->{author_date} = $git->timestamp($author_date);
$commit->{committer_date} = $git->timestamp($committer_date);
$from_id = $commit->{parent} unless defined $from_id;
# Branches
my $branch_refs = $git->references($user, $project, 'heads');
my $branches = $branch_refs->{$commit->{id}} || [];
# Tags
my $tag_refs = $git->references($user, $project, 'tags');
my $tags = $tag_refs->{$commit->{id}} || [];
# Global variable for included template
stash(
id => $id,
from_id => $from_id,
rev => $id,
commit => $commit,
parents => $commit->{parents}
);
%>
% layout 'common';
%= include '/include/header', title => 'Commit diff';
<div class="container">
%= include '/include/project_header';
%= include '/include/code_menu', display => 'commits';
<div class="bk-blue-light border-gray" style="border-bottom:none;padding:10px;border-top-left-radius:5px;border-top-right-radius:5px">
<div class="row">
<div class="span10">
<big>
% if ($commit->{title_short} eq $commit->{title}) {
<b><%= $commit->{title_short} %></b>;
% } else {
<%
my $title_short = $commit->{title_short};
$title_short =~ s/\.\.\.\s*$//;
my $title_tail = $commit->{title};
$title_tail =~ s/^\Q$title_short//;
$title_tail =~ s/^\s+//;
%>
<p style="margin-bottom:2px;"><b><%= $title_short %>...</b></p>
<p style="margin-top:2px;margin-bottom:15px;">...<%= $title_tail %></p>
% }
</big>
</div>
<div class="text-right">
<a class="btn btn-primary" href="<%= url_for("/$user/$project/tree/$commit->{id}") %>">
Browse code
</a>
</div>
</div>
% if (@{$commit->{comment}} > 1) {
<div class="border-bottom-gray" style="padding-left:15px;padding-bottom:5px">
% for (my $i = 1; $i < @{$commit->{comment}}; $i++) {
<div>
<%= $commit->{comment}[$i] %>
</div>
% }
</div>
% }
% if (@$branches || @$tags) {
<div class="broder-top-gray" style="padding-top:7px">
% for my $branch (@$branches) {
<span style="padding-left:5px">
<i class="icon-share-alt"></i><a href="<%= url_for("/$user/$project/commit/$branch") %>"><%= $branch %></a>
</span>
% }
% for my $tag (@$tags) {
<span style="padding-left:5px">
<i class="icon-tag"></i><a href="<%= url_for("/$user/$project/commit/$tag") %>"><%= $tag %></a>
</span>
% }
</div>
% }
</div>
<div class="border-gray" style="border-bottom-left-radius:5px;border-bottom-right-radius:5px;margin-bottom:10px;">
<div class="row">
<div class="span4" style="padding:5px">
<span><b><%= $commit->{author_name} %></b></span>
<span class="muted">authored <span title="<%= $commit->{age_string_datetime} %>"><%= $commit->{age_string} %></span>
</div>
<div class="span7 text-right" style="padding:5px;margin-left:75px">
% my $parent = $commit->{parent};
% my $parents = $commit->{parents};
% if (!defined $parent) {
0 <span class="muted">parent</span>
% } elsif (@$parents == 1) {
1 <span class="muted">parent</span>
<a class="font-black" href="<%= url_for("/$user/$project/commit/$parent") %>">
<%= substr($parent, 0, 7) %>
</a>
% } else {
<%= @$parents %> <span class="muted">parents</span>:
% for my $parent (@$parents) {
<a class="font-black" href="<%= url_for("/$user/$project/commit/$parent") %>">
<%= substr($parent, 0, 7) %>
</a>
% }
% }
<span class="muted">commit</span> <%= $commit->{id} %>
</div>
</div>
</div>
%= include '/include/commit_body';
%= include '/include/footer';