Also tidied added to diff tree output.
}
sub _get_commit {
- my($self, $c) = @_;
+ my($self, $c, $haveh) = @_;
- my $h = $c->req->param('h');
+ my $h = $haveh || $c->req->param('h');
my $f = $c->req->param('f');
my $m = $c->model('Git');
log_lines => [$c->model('Git')->list_revs(%logargs)],
refs => $c->model('Git')->references,
action => 'shortlog',
- page => $page + 1,
+ page => $page,
);
}
sub tree : Local {
my ( $self, $c ) = @_;
- my $commit = $self->_get_commit($c);
+ my $commit = $self->_get_commit($c, $c->req->param('hb'));
+ my $tree = $c->model('Git')->get_object($c->req->param('h') || $commit->tree_sha1);
$c->stash(
# XXX Useful defaults needed ...
commit => $commit,
- tree => $c->model('Git')->get_object($c->req->param('hb')),
- tree_list => [$c->model('Git')->list_tree($commit->sha1)],
+ tree => $tree,
+ tree_list => [$c->model('Git')->list_tree($tree->sha1)],
+ path => $c->req->param('f') || '',
action => 'tree',
);
}
my @keys = qw(modesrc modedst sha1src sha1dst status src dst);
my @ret;
- while($diff->[0] =~ /^:\d+/) {
- local $_ = shift @$diff;
+ while(@$diff and $diff->[0] =~ /^:\d+/) {
+ my $line = shift @$diff;
# see. man git-diff-tree for more info
# mode src, mode dst, sha1 src, sha1 dst, status, src[, dst]
- my @vals = /^:(\d+) (\d+) ($SHA1RE) ($SHA1RE) ([ACDMRTUX])\t([^\t]+)(?:\t([^\n]+))?$/;
+ my @vals = $line =~ /^:(\d+) (\d+) ($SHA1RE) ($SHA1RE) ([ACDMRTUX]\d*)\t([^\t]+)(?:\t([^\n]+))?$/;
my %line = zip @keys, @vals;
# Some convenience keys
$line{file} = $line{src};
$line{sha1} = $line{sha1dst};
- $line{is_new} = $line{sha1src} =~ /^0+$/;
+ $line{is_new} = $line{sha1src} =~ /^0+$/
+ if $line{sha1src};
+ @line{qw/status sim/} = $line{status} =~ /(R)(\d+)/
+ if $line{status} =~ /^R/;
push @ret, \%line;
}
+/* XXX A good framework would be handy */
+/* XXX Also colours. Lots of colours. */
#body {
- margin: 1em;
+ margin: 1em;
}
#commit-nav {
- padding-bottom: 4px;
- border-bottom: solid 1px #ccc;
- font-style: italic;
+ padding-bottom: 4px;
+ border-bottom: solid 1px #ccc;
+ font-style: italic;
+}
+
+thead, tfoot {
+ color: #ddd;
+ font-size: small;
+ font-weight: bold;
}
/* /commit page */
.commit-message {
- font-family: monospace;
+ font-family: monospace;
}
div.commit-message {
- background-color: #ddd;
- padding: 5px;
+ background-color: #ddd;
+ padding: 5px;
}
.commit-info dt {
- font-weight: bold;
+ font-weight: bold;
}
.commit-info dd {
- font-family: monospace;
+ font-family: monospace;
}
.filename {
}
.path {
- border-bottom: solid 1px #ddd;
- padding: 3px 0;
- font-weight: bold;
+ border-bottom: solid 1px #ddd;
+ padding: 3px 0;
+ font-weight: bold;
}
/* /heads */
.heads .head {
- font-weight: bold;
+ font-weight: bold;
}
.heads .current {
- text-decoration: underline;
+ text-decoration: underline;
}
/* /blob */
pre.blob {
- background-color: #333;
- color: #ddd;
- border-left: solid 3px #c33;
- padding: 5px;
- padding-left: 15px;
- margin: 10px 15px;
+ background-color: #333;
+ color: #ddd;
+ border-left: solid 3px #c33;
+ padding: 5px;
+ padding-left: 15px;
+ margin: 10px 15px;
}
<thead>
<tr>
<td>file</td>
+ <td>status</td>
<td>actions</td>
</tr>
</thead>
<tbody>
- [% FOREACH line IN diff_tree %]
+ [% FOREACH line IN diff_tree -%]
<tr>
- <td class='filename'>[% line.src %]</td>
+ <td class='filename'>
+ [% line.file %]
+ </td>
+ <td class='status'>
+ [%
+ SWITCH line.status;
+ CASE 'R';
+ '[moved from ' _ line.src _ ' with ' _ line.sim _ '% similarity]';
+ CASE 'A';
+ '[new file with mode: ' _ line.modedst _ ']';
+ CASE 'D';
+ '[deleted file]';
+ END;
+ %]
+ </td>
<td class='action-list'>
[% IF !line.is_new %]<a href="/blobdiff?p=[% project %];f=[% line.file %];h=[% commit.sha1 %];hp=[% commit.parent_sha1 %]">diff</a>[% END %]
<a href="/blob?p=[% project %];f=[% line.file %];h=[% line.sha1 %];hb=[% commit.sha1 %]">blob</a>
<tfoot>
<tr>
<td>file</td>
+ <td>status</td>
<td>actions</td>
</tr>
</tfoot>
<div class='pager'>
<a href='/[% action %]?p=[% project %];h=[% HEAD %]'>HEAD</a>
[% IF log_lines.size == 50 %]
- <a href='/[% action %]?p=[% project %];h=[% commit.sha1 %];pg=[% page %]'>next</a>
+ <a href='/[% action %]?p=[% project %];h=[% commit.sha1 %];pg=[% page + 1 %]'>next</a>
[% END %]
- [% IF log_lines.first.sha1 != HEAD %]
+ [% IF log_lines.first.sha1 != commit.sha1 %]
<a href='/[% action %]?p=[% project %];h=[% commit.sha1 %];pg=[% page - 1 %]'>prev</a>
[% END %]
</div>
-[% INCLUDE '_log_pager.tt2' %]
<table>
<thead>
<tr>
</tr>
</tfoot>
</table>
-[% INCLUDE '_log_pager.tt2' %]
<td>[% item.modestr %]</td>
[% theact = item.type == 'tree' ? 'tree' : 'blob' -%]
<td class='filename'>
- <a href="/[% theact %]?h=[% item.object %];hb=[% commit.sha1 %];f=[% item.file %]">[% item.file %]</a>
+ <a href="/[% theact %]?p=[% project %];h=[% item.object %];hb=[% commit.sha1 %];f=[% IF path; path _ '/'; END; item.file %]">[% item.file %]</a>
</td>
<td class='action-list'>
<a href="/[% theact %]?p=[% project %];h=[% item.object %];hb=[% commit.sha1 %];f=[% item.file %]">[% theact %]</a>
</tr>
</tfoot>
</table>
-
<a href="/log?p=[% project %];h=[% object.sha1 %]">log</a> |
<a href="/commit?p=[% project %];h=[% object.sha1 %]">commit</a> |
<a href="/commitdiff?p=[% project %];h=[% object.sha1 %]">commitdiff</a> |
- <a href="/tree?p=[% project %];h=[% object.tree_sha1 %]">tree</a>
+ <a href="/tree?p=[% project %];h=[% object.tree_sha1 %];hb=[% object.sha1 %]">tree</a>
</div>
<dt>commit</dt>
<dd>[% commit.sha1 %]</dd>
<dt>tree</dt>
- <dd>[% commit.tree_sha1 %] <a href="/tree?p=[% project %];h=[% commit.sha1 %];hb=[% commit.tree_sha1 %]">tree</a></dd>
+ <dd>[% commit.tree_sha1 %]
+ <span class='action-list'><a href="/tree?p=[% project %];h=[% commit.tree_sha1 %];hb=[% commit.sha1 %]">tree</a></span>
+ </dd>
[% FOREACH parent IN commit.parents %]
<dt>parent</dt>
<dd>[% parent %]
[% project %]
</div>
-[% INCLUDE '_shortlog.tt2' %]
+[%
+INCLUDE '_log_pager.tt2';
+INCLUDE '_shortlog.tt2';
+INCLUDE '_log_pager.tt2';
+%]
</div>
<div class='shortlog'>
-<h2>shortlog</h2>
+<h2><a href='/shortlog?p=[% project %]'>shortlog</a></h2>
[% INCLUDE '_shortlog.tt2' %]
</div>
<div class='heads'>
-<h2>heads</h2>
+<h2><a href='/heads?p=[% project %]'>heads</a></h2>
[% INCLUDE '_heads.tt2' %]
</div>
[% commit.comment.substr(0, 85) %] ...
</div>
+[% IF path -%]
+<div>
+ <a href='/tree?p=[% project %];hb=[% commit.sha1 %]'>[% project %]</a>
+ [% fullpath = ''-%]
+ [% FOREACH part IN path.split('/') -%]
+ / <a href='/tree?p=[% project %];h=[% tree.sha1 %];hb=[% commit.sha1 %];f=[% fullpath _ part %]'>[% part %]</a>
+ [% fullpath = fullpath _ part _ '/'; %]
+ [% END -%]
+</div>
+[% END -%]
+
[% INCLUDE '_tree.tt2' %]