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