X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FGitalist%2FController%2FFragment%2FRef.pm;h=a6690e6e4a57773c675626733b7d0fce89cbbf48;hb=9912b0623977f9e2e5fdf9e3b87829c72fe6ef83;hp=9793dd79467b837c58d9d83c8b970df6e5b6fc5f;hpb=1064e5b8d484d1007295d0325a82a80801ad14b9;p=catagits%2FGitalist.git diff --git a/lib/Gitalist/Controller/Fragment/Ref.pm b/lib/Gitalist/Controller/Fragment/Ref.pm index 9793dd7..a6690e6 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) {} @@ -116,4 +117,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;