Commit | Line | Data |
0da7966e |
1 | package Gitalist::URIStructure::Commit; |
2 | use MooseX::MethodAttributes::Role; |
b6ec181b |
3 | use Moose::Autobox; |
0da7966e |
4 | use namespace::autoclean; |
5 | |
6 | requires 'base'; |
7 | |
8 | after 'base' => sub { |
9 | my ($self, $c) = @_; |
10 | confess("No repository in the stash") |
11 | unless $c->stash->{Repository}; |
12 | }; |
13 | |
14 | sub find : Chained('base') PathPart('') CaptureArgs(1) { |
15 | my ($self, $c, $sha1part) = @_; |
16 | # FIXME - Should not be here! |
dcb1b927 |
17 | $c->stash->{Commit} = $c->stash->{Repository}->get_object_or_head($sha1part) |
0da7966e |
18 | or $c->detach('/error404', "Couldn't find a object for '$sha1part' in XXXX!"); |
19 | } |
20 | |
d361d955 |
21 | sub diff : Chained('find') CaptureArgs(0) {} |
22 | |
23 | sub diff_fancy : Chained('diff') PathPart('') Args(0) {} |
24 | |
25 | sub diff_plain : Chained('diff') PathPart('plain') Args(0) {} |
0da7966e |
26 | |
bec3aecb |
27 | sub commit : Chained('find') PathPart('commit') Args(0) {} |
0da7966e |
28 | |
b6ec181b |
29 | sub tree : Chained('find') Does('FilenameArgs') Args() {} |
0da7966e |
30 | |
ca06a177 |
31 | sub 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 |
39 | sub blob : Chained('find') Does('FilenameArgs') Args() { |
40 | my ($self, $c) = @_; |
41 | $c->forward('find_blob'); |
42 | } |
1f9a47c2 |
43 | |
b6ec181b |
44 | sub blame : Chained('find') Does('FilenameArgs') Args() {} |
1f9a47c2 |
45 | |
b6ec181b |
46 | sub history : Chained('find') Does('FilenameArgs') Args() {} |
47 | |
b6ec181b |
48 | sub shortlog : Chained('find') Does('FilenameArgs') Args() {} |
1f9a47c2 |
49 | |
0da7966e |
50 | 1; |