Commit | Line | Data |
f6a72048 |
1 | package Gitalist::Controller::Commit; |
2 | |
3 | use Moose; |
f6a72048 |
4 | use namespace::autoclean; |
5 | |
b6ec181b |
6 | BEGIN { extends 'Gitalist::Controller' } |
0da7966e |
7 | with 'Gitalist::URIStructure::Commit'; |
f6a72048 |
8 | |
9 | sub base : Chained('/repository/find') PathPart('') CaptureArgs(0) {} |
10 | |
ca06a177 |
11 | sub raw : Chained('find') Does('FilenameArgs') Args() { |
b132dce6 |
12 | my ($self, $c) = @_; |
ca06a177 |
13 | $c->forward('find_blob'); |
b132dce6 |
14 | |
15 | $c->response->content_type('text/plain; charset=utf-8'); |
16 | $c->response->body(delete $c->stash->{blob}); |
17 | } |
18 | |
19 | =head2 snapshot |
20 | |
21 | Provides a snapshot of a given commit. |
22 | |
23 | =cut |
24 | |
25 | sub snapshot : Chained('base') Args() { |
26 | my ($self, $c, $format) = @_; |
27 | $format ||= 'tgz'; |
28 | my @snap = $c->stash->{Repository}->snapshot( |
29 | sha1 => $c->stash->{Commit}->sha1, |
30 | format => $format |
31 | ); |
32 | $c->response->status(200); |
33 | $c->response->headers->header( 'Content-Disposition' => |
34 | "attachment; filename=$snap[0]"); |
35 | $c->response->body($snap[1]); |
36 | } |
37 | |
8fd20a28 |
38 | =head2 patch |
39 | |
40 | A raw patch for a given commit. |
41 | |
42 | =cut |
43 | |
44 | sub patch : Chained('find') Args(0) { |
45 | my ($self, $c) = @_; |
46 | $c->detach('patches', [1]); |
47 | } |
48 | |
49 | =head2 patches |
50 | |
51 | The patcheset for a given commit ??? |
52 | |
53 | =cut |
54 | |
55 | sub patches : Chained('find') Args(1) { |
56 | my ($self, $c, $count) = @_; |
57 | $count ||= Gitalist->config->{patches}{max}; |
58 | my $commit = $c->stash->{Commit}; |
59 | my $parent = $c->req->param('hp') || undef; # FIXME |
60 | my $patch = $commit->get_patch( $parent, $count ); |
61 | $c->response->body($patch); |
62 | $c->response->content_type('text/plain'); |
63 | $c->response->status(200); |
64 | } |
65 | |
f6a72048 |
66 | __PACKAGE__->meta->make_immutable; |