Make the log work for commits and symbolic refs also.
[catagits/Gitalist.git] / lib / Gitalist / URIStructure / Repository.pm
1 package Gitalist::URIStructure::Repository;
2 use MooseX::MethodAttributes::Role;
3 use Try::Tiny qw/try catch/;
4 use namespace::autoclean;
5
6 requires 'base';
7
8 with qw/
9     Gitalist::URIStructure::WithLog
10 /;
11
12 sub find : Chained('base') PathPart('') CaptureArgs(1) {
13     my ($self, $c, $repos_name) = @_;
14     # XXX FIXME - This should be in the repository fragment controller, and the repository
15     #             controller should just check has_repository
16     try {
17         my $repos = $c->model()->get_repository($repos_name);
18         $c->stash(
19             Repository => $repos,
20             HEAD => $repos->head_hash,
21         );
22     }
23     catch {
24         $c->detach('/error_404');
25     };
26 }
27
28 before 'log' => sub {
29     my ($self, $c) = @_;
30     $c->stash->{Commit} = $c->stash->{Repository}->get_object($c->stash->{Repository}->head_hash);
31 };
32
33 sub summary : Chained('find') PathPart('') Args(0) {}
34
35 sub heads : Chained('find') Args(0) {}
36
37 sub tags : Chained('find') Args(0) {}
38
39 1;