From: broquaint Date: Wed, 28 Oct 2009 21:51:47 +0000 (+0000) Subject: Fleshed out the /tree action and fixed paging. X-Git-Tag: 0.000000_01~108^2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b4b4d0fd18a6a83a75b4d71408b8acbfedd90fb6;hp=14664e1c094097ee454e254d2b40128c240a6e2e;p=catagits%2FGitalist.git Fleshed out the /tree action and fixed paging. Also tidied added to diff tree output. --- diff --git a/lib/Gitalist/Controller/Root.pm b/lib/Gitalist/Controller/Root.pm index 9ec74e1..394d64d 100644 --- a/lib/Gitalist/Controller/Root.pm +++ b/lib/Gitalist/Controller/Root.pm @@ -58,9 +58,9 @@ sub run_gitweb { } 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'); @@ -273,7 +273,7 @@ sub shortlog : Local { log_lines => [$c->model('Git')->list_revs(%logargs)], refs => $c->model('Git')->references, action => 'shortlog', - page => $page + 1, + page => $page, ); } @@ -296,12 +296,14 @@ The tree of a given commit. 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', ); } diff --git a/lib/Gitalist/Model/Git.pm b/lib/Gitalist/Model/Git.pm index 8c6f23b..814321a 100644 --- a/lib/Gitalist/Model/Git.pm +++ b/lib/Gitalist/Model/Git.pm @@ -538,16 +538,19 @@ sub parse_diff_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; } diff --git a/root/static/css/site.css b/root/static/css/site.css index e06ec3d..f62959e 100644 --- a/root/static/css/site.css +++ b/root/static/css/site.css @@ -1,26 +1,34 @@ +/* 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 { @@ -31,25 +39,25 @@ div.commit-message { } .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; } diff --git a/templates/_diff_tree.tt2 b/templates/_diff_tree.tt2 index c46bbb2..7544ab4 100644 --- a/templates/_diff_tree.tt2 +++ b/templates/_diff_tree.tt2 @@ -2,13 +2,28 @@ file + status actions - [% FOREACH line IN diff_tree %] + [% FOREACH line IN diff_tree -%] - [% line.src %] + + [% line.file %] + + + [% + 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; + %] + [% IF !line.is_new %]diff[% END %] blob @@ -20,6 +35,7 @@ file + status actions diff --git a/templates/_log_pager.tt2 b/templates/_log_pager.tt2 index d91c406..3c4c1d9 100644 --- a/templates/_log_pager.tt2 +++ b/templates/_log_pager.tt2 @@ -1,9 +1,9 @@
HEAD [% IF log_lines.size == 50 %] - next + next [% END %] - [% IF log_lines.first.sha1 != HEAD %] + [% IF log_lines.first.sha1 != commit.sha1 %] prev [% END %]
diff --git a/templates/_shortlog.tt2 b/templates/_shortlog.tt2 index 5d96591..329dcd1 100644 --- a/templates/_shortlog.tt2 +++ b/templates/_shortlog.tt2 @@ -1,4 +1,3 @@ -[% INCLUDE '_log_pager.tt2' %] @@ -45,4 +44,3 @@
-[% INCLUDE '_log_pager.tt2' %] diff --git a/templates/_tree.tt2 b/templates/_tree.tt2 index e39b1a5..f7f1bb1 100644 --- a/templates/_tree.tt2 +++ b/templates/_tree.tt2 @@ -13,7 +13,7 @@ [% item.modestr %] [% theact = item.type == 'tree' ? 'tree' : 'blob' -%] - [% item.file %] + [% item.file %] [% theact %] @@ -32,4 +32,3 @@ - diff --git a/templates/commit-nav.tt2 b/templates/commit-nav.tt2 index 4954dfb..24f38bb 100644 --- a/templates/commit-nav.tt2 +++ b/templates/commit-nav.tt2 @@ -4,5 +4,5 @@ log | commit | commitdiff | - tree + tree diff --git a/templates/commit.tt2 b/templates/commit.tt2 index 97294f0..c671f41 100644 --- a/templates/commit.tt2 +++ b/templates/commit.tt2 @@ -17,7 +17,9 @@
commit
[% commit.sha1 %]
tree
-
[% commit.tree_sha1 %] tree
+
[% commit.tree_sha1 %] + tree +
[% FOREACH parent IN commit.parents %]
parent
[% parent %] diff --git a/templates/shortlog.tt2 b/templates/shortlog.tt2 index b49e0e8..c8e9ef2 100644 --- a/templates/shortlog.tt2 +++ b/templates/shortlog.tt2 @@ -4,4 +4,8 @@ [% project %] -[% INCLUDE '_shortlog.tt2' %] +[% +INCLUDE '_log_pager.tt2'; +INCLUDE '_shortlog.tt2'; +INCLUDE '_log_pager.tt2'; +%] diff --git a/templates/summary.tt2 b/templates/summary.tt2 index 2eb2e8a..f320ffc 100644 --- a/templates/summary.tt2 +++ b/templates/summary.tt2 @@ -9,11 +9,11 @@
-

shortlog

+

shortlog

[% INCLUDE '_shortlog.tt2' %]
-

heads

+

heads

[% INCLUDE '_heads.tt2' %]
diff --git a/templates/tree.tt2 b/templates/tree.tt2 index 8583cae..7b55830 100644 --- a/templates/tree.tt2 +++ b/templates/tree.tt2 @@ -4,4 +4,15 @@ [% commit.comment.substr(0, 85) %] ... +[% IF path -%] +
+ [% project %] + [% fullpath = ''-%] + [% FOREACH part IN path.split('/') -%] + / [% part %] + [% fullpath = fullpath _ part _ '/'; %] + [% END -%] +
+[% END -%] + [% INCLUDE '_tree.tt2' %]