The blame view now looks similar to the blob so a bit easier on the eyes.
[catagits/Gitalist.git] / lib / Gitalist / URIStructure / Commit.pm
CommitLineData
0da7966e 1package Gitalist::URIStructure::Commit;
2use MooseX::MethodAttributes::Role;
b6ec181b 3use Moose::Autobox;
0da7966e 4use namespace::autoclean;
5
6requires 'base';
7
8after 'base' => sub {
9 my ($self, $c) = @_;
10 confess("No repository in the stash")
11 unless $c->stash->{Repository};
12};
13
14sub find : Chained('base') PathPart('') CaptureArgs(1) {
15 my ($self, $c, $sha1part) = @_;
16 # FIXME - Should not be here!
17 $c->stash->{Commit} = $c->stash->{Repository}->get_object($sha1part)
18 or $c->detach('/error404', "Couldn't find a object for '$sha1part' in XXXX!");
19}
20
d361d955 21sub diff : Chained('find') CaptureArgs(0) {}
22
23sub diff_fancy : Chained('diff') PathPart('') Args(0) {}
24
25sub diff_plain : Chained('diff') PathPart('plain') Args(0) {}
0da7966e 26
b6ec181b 27sub commit : Chained('find') PathPart('') Args(0) {}
0da7966e 28
b6ec181b 29sub tree : Chained('find') Does('FilenameArgs') Args() {}
0da7966e 30
ca06a177 31sub find_blob : Action {
b132dce6 32 my ($self, $c) = @_;
33 # FIXME - Eugh!
34 my $h = $c->stash->{Repository}->hash_by_path($c->stash->{Commit}->sha1, $c->stash->{filename})
35 || die "No file or sha1 provided.";
36 $c->stash(blob => $c->stash->{Repository}->get_object($h)->content);
37}
1f9a47c2 38
ca06a177 39sub blob : Chained('find') Does('FilenameArgs') Args() {
40 my ($self, $c) = @_;
41 $c->forward('find_blob');
42}
1f9a47c2 43
b6ec181b 44sub blame : Chained('find') Does('FilenameArgs') Args() {}
1f9a47c2 45
b6ec181b 46sub history : Chained('find') Does('FilenameArgs') Args() {}
47
b6ec181b 48sub shortlog : Chained('find') Does('FilenameArgs') Args() {}
1f9a47c2 49
0da7966e 501;