From: broquaint Date: Fri, 23 Oct 2009 16:16:39 +0000 (+0100) Subject: Added first cut of /shortlog action and simplified the parse_rev_list() method. X-Git-Tag: 0.000000_01~108^2~16 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=47495599588ae86769d675a239cbca6b07a36aa0;p=catagits%2FGitalist.git Added first cut of /shortlog action and simplified the parse_rev_list() method. --- diff --git a/lib/Gitalist/Controller/Root.pm b/lib/Gitalist/Controller/Root.pm index 06c0a8e..7fac165 100644 --- a/lib/Gitalist/Controller/Root.pm +++ b/lib/Gitalist/Controller/Root.pm @@ -129,7 +129,7 @@ sub reflog : Local { =head2 commit -Exposes a given commit. Probably too simple currently. +Exposes a given commit. =cut @@ -142,6 +142,21 @@ sub commit : Local { ); } +=head2 shortlog + +Expose an abbreviated log of a given sha1. + +=cut + +sub shortlog : Local { + my ( $self, $c ) = @_; + + $c->stash( + commit => $c->model('Git')->get_object($c->req->param('h')), + action => 'shortlog', + ); +} + =head2 auto Populate the header and footer. Perhaps not the best location. diff --git a/lib/Gitalist/Model/Git.pm b/lib/Gitalist/Model/Git.pm index 0deef1a..aa45676 100644 --- a/lib/Gitalist/Model/Git.pm +++ b/lib/Gitalist/Model/Git.pm @@ -425,62 +425,30 @@ sub diff { return $output; } -{ - my $formatter = DateTime::Format::Mail->new; - =head2 parse_rev_list Given the output of the C command return a list of hashes. =cut - sub parse_rev_list { - my ($self, $output) = @_; - my @ret; - - my @revs = split /\0/, $output; - - for my $rev (split /\0/, $output) { - for my $line (split /\n/, $rev, 6) { - chomp $line; - next unless $line; - - if ($self->valid_rev($line)) { - push @ret, {rev => $line}; - next; - } - - if (my ($key, $value) = $line =~ /^(tree|parent)\s+(.*)$/) { - $ret[-1]->{$key} = $value; - next; - } - - if (my ($key, $value, $epoch, $tz) = $line =~ /^(author|committer)\s+(.*)\s+(\d+)\s+([+-]\d+)$/) { - $ret[-1]->{$key} = $value; - eval { - $ret[-1]->{ $key . "_datetime" } = DateTime->from_epoch(epoch => $epoch); - $ret[-1]->{ $key . "_datetime" }->set_time_zone($tz); - $ret[-1]->{ $key . "_datetime" }->set_formatter($formatter); - }; - - if ($@) { - $ret[-1]->{ $key . "_datetime" } = "$epoch $tz"; - } - - if (my ($name, $email) = $value =~ /^([^<]+)\s+<([^>]+)>$/) { - $ret[-1]->{ $key . "_name" } = $name; - $ret[-1]->{ $key . "_email" } = $email; - } - } - - $line =~ s/^\n?\s{4}//; - $ret[-1]->{longmessage} = $line; - $ret[-1]->{message} = (split /\n/, $line, 2)[0]; - } - } +sub parse_rev_list { + my ($self, $output) = @_; + my @ret; + + my @revs = split /\0/, $output; - return @ret; + for my $rev (split /\0/, $output) { + for my $line (split /\n/, $rev, 6) { + chomp $line; + next unless $line; + + if ($self->valid_rev($line)) { + push @ret, $self->get_object($line); + } + } } + + return @ret; } =head2 list_revs diff --git a/lib/Gitalist/View/SyntaxHighlight.pm b/lib/Gitalist/View/SyntaxHighlight.pm index c030f03..da9e6b7 100644 --- a/lib/Gitalist/View/SyntaxHighlight.pm +++ b/lib/Gitalist/View/SyntaxHighlight.pm @@ -13,6 +13,8 @@ use HTML::Entities qw(encode_entities); sub process { my($self, $c) = @_; + # If we're not going to highlight the blob unsure that it's ready to go + # into HTML at least. if($c->stash->{filename} =~ /\.p[lm]$/) { # via # http://github.com/jrockway/angerwhale/blob/master/lib/Angerwhale/Format/Pod.pm#L136 diff --git a/root/static/css/site.css b/root/static/css/site.css index 2941275..4d05680 100644 --- a/root/static/css/site.css +++ b/root/static/css/site.css @@ -11,6 +11,8 @@ /* /commit page */ .commit-message { font-family: monospace; +} +div.commit-message { background-color: #ddd; padding: 5px; } diff --git a/templates/commit.tt2 b/templates/commit.tt2 index bb029eb..82db3d7 100644 --- a/templates/commit.tt2 +++ b/templates/commit.tt2 @@ -1,6 +1,6 @@ [% INCLUDE 'commit-nav.tt2' object = commit %]
-[% commit.comment.substr(0, 50) %] ... +[% commit.comment.substr(0, 85) %] ... [% FOREACH ref IN c.model('Git').refs_for(commit.sha1) %] [% ref %] [% END %] @@ -27,8 +27,10 @@ - - + + + + [% FOREACH line IN c.model('Git').diff_tree(commit) %] @@ -43,8 +45,10 @@ [% END %] - - + + + +
fileactions
fileactions
fileactions
fileactions
diff --git a/templates/shortlog.tt2 b/templates/shortlog.tt2 new file mode 100644 index 0000000..6211d3b --- /dev/null +++ b/templates/shortlog.tt2 @@ -0,0 +1,40 @@ +[% INCLUDE 'commit-nav.tt2' object = commit %] + +
+[% project %] +
+ + + + + + + + + + + + + [% FOREACH line IN c.model('Git').list_revs('rev', commit.sha1) %] + + + + + + + [% END %] + + + + + + + + + + +
timeauthormessageactions
[% line.authored_time %][% line.author.name | html %][% '[' _ line.sha1.substr(0, 6) _ '] ' _ line.comment.substr(0, 50) | html %] + commit + commitdiff + history +
timeauthormessageactions