X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FGitalist%2FURIStructure%2FCommit.pm;h=01bb7615b971703ae195eafe13a6b3f8faebcf6e;hb=dcb1b9274df97bb163f7c0fb3b9aa80c31255cae;hp=e59e64cc6cff6fdd9cc02bce187d968b748a5d52;hpb=1b33f63b3716cd809deb356f89bffac3182134d3;p=catagits%2FGitalist.git diff --git a/lib/Gitalist/URIStructure/Commit.pm b/lib/Gitalist/URIStructure/Commit.pm index e59e64c..01bb761 100644 --- a/lib/Gitalist/URIStructure/Commit.pm +++ b/lib/Gitalist/URIStructure/Commit.pm @@ -1,5 +1,6 @@ package Gitalist::URIStructure::Commit; use MooseX::MethodAttributes::Role; +use Moose::Autobox; use namespace::autoclean; requires 'base'; @@ -13,7 +14,7 @@ after 'base' => sub { sub find : Chained('base') PathPart('') CaptureArgs(1) { my ($self, $c, $sha1part) = @_; # FIXME - Should not be here! - $c->stash->{Commit} = $c->stash->{Repository}->get_object($sha1part) + $c->stash->{Commit} = $c->stash->{Repository}->get_object_or_head($sha1part) or $c->detach('/error404', "Couldn't find a object for '$sha1part' in XXXX!"); } @@ -23,8 +24,27 @@ sub diff_fancy : Chained('diff') PathPart('') Args(0) {} sub diff_plain : Chained('diff') PathPart('plain') Args(0) {} -sub tree : Chained('find') Args() {} +sub commit : Chained('find') PathPart('') Args(0) {} -sub commit : Chained('find') PathPart('') {} +sub tree : Chained('find') Does('FilenameArgs') Args() {} + +sub find_blob : Action { + my ($self, $c) = @_; + # FIXME - Eugh! + my $h = $c->stash->{Repository}->hash_by_path($c->stash->{Commit}->sha1, $c->stash->{filename}) + || die "No file or sha1 provided."; + $c->stash(blob => $c->stash->{Repository}->get_object($h)->content); +} + +sub blob : Chained('find') Does('FilenameArgs') Args() { + my ($self, $c) = @_; + $c->forward('find_blob'); +} + +sub blame : Chained('find') Does('FilenameArgs') Args() {} + +sub history : Chained('find') Does('FilenameArgs') Args() {} + +sub shortlog : Chained('find') Does('FilenameArgs') Args() {} 1;