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 | |
b132dce6 |
11 | sub blob_plain : Chained('find_blob') Does('FilenameArgs') Args() { |
12 | my ($self, $c) = @_; |
13 | |
14 | $c->response->content_type('text/plain; charset=utf-8'); |
15 | $c->response->body(delete $c->stash->{blob}); |
16 | } |
17 | |
18 | =head2 snapshot |
19 | |
20 | Provides a snapshot of a given commit. |
21 | |
22 | =cut |
23 | |
24 | sub snapshot : Chained('base') Args() { |
25 | my ($self, $c, $format) = @_; |
26 | $format ||= 'tgz'; |
27 | my @snap = $c->stash->{Repository}->snapshot( |
28 | sha1 => $c->stash->{Commit}->sha1, |
29 | format => $format |
30 | ); |
31 | $c->response->status(200); |
32 | $c->response->headers->header( 'Content-Disposition' => |
33 | "attachment; filename=$snap[0]"); |
34 | $c->response->body($snap[1]); |
35 | } |
36 | |
f6a72048 |
37 | __PACKAGE__->meta->make_immutable; |