From: Dan Brook Date: Fri, 23 Apr 2010 22:41:20 +0000 (+0100) Subject: Proof of concept for #56388: add last commit msg to tre views. X-Git-Tag: 0.002001_01~22 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FGitalist.git;a=commitdiff_plain;h=5dc23a1461cf1feff56e1ca7e8e118a2b0259c6f Proof of concept for #56388: add last commit msg to tre views. --- diff --git a/lib/Gitalist/Controller/Fragment/Ref.pm b/lib/Gitalist/Controller/Fragment/Ref.pm index 14f8561..f110803 100644 --- a/lib/Gitalist/Controller/Fragment/Ref.pm +++ b/lib/Gitalist/Controller/Fragment/Ref.pm @@ -9,6 +9,7 @@ with qw/ /; use File::Type::WebImages (); +use JSON::XS qw(encode_json); sub base : Chained('/fragment/repository/find') PathPart('') CaptureArgs(0) {} @@ -115,4 +116,24 @@ after history => sub { ); }; +after file_commit_info => sub { + my ($self, $c) = @_; + + my $repository = $c->stash->{Repository}; + + my($commit) = $repository->list_revs( + sha1 => $c->stash->{Commit}->sha1, + count => 1, + file => $c->stash->{filename}, + ); + + my $json_obj = $commit + ? { sha1 => $commit->sha1, comment => $c->stash->{short_cmt}->($commit->comment) } + : { }; + + $c->response->content_type('application/json'); + # XXX Make use of the json branch + $c->response->body( encode_json $json_obj ); +}; + __PACKAGE__->meta->make_immutable; diff --git a/lib/Gitalist/URIStructure/Ref.pm b/lib/Gitalist/URIStructure/Ref.pm index 20337fe..da71487 100644 --- a/lib/Gitalist/URIStructure/Ref.pm +++ b/lib/Gitalist/URIStructure/Ref.pm @@ -55,6 +55,8 @@ sub diff_plain : Chained('diff') PathPart('plain') Args() { sub commit : Chained('find') PathPart('commit') Args(0) {} +sub file_commit_info : Chained('find') Does('FilenameArgs') Args() {} + sub tree : Chained('find') Does('FilenameArgs') Args() {} sub find_blob : Action { diff --git a/root/fragment/ref/tree.tt2 b/root/fragment/ref/tree.tt2 index b043808..38ecf21 100755 --- a/root/fragment/ref/tree.tt2 +++ b/root/fragment/ref/tree.tt2 @@ -1,14 +1,28 @@ + + + [% BLOCK tree_table_headfoot %] [% SET cell = type == 'head' ? 'th' : 'td' %] <[% cell %]>Mode <[% cell %]>Folder / File <[% cell %]>Actions + <[% cell %]>Message [% END %] - - [%- SET counter = 1; @@ -43,6 +57,7 @@ [% END %] Short log + Loading commit info ... [% counter = counter + 1 %] [% END %] @@ -51,7 +66,7 @@ - +
[% PROCESS tree_table_headfoot type = 'head' %] [% INCLUDE output_tree tree_type => tree_folders %]