Delete some now unused templates. Bring the history templates back from the dead
[catagits/Gitalist.git] / lib / Gitalist / Controller / Commit.pm
CommitLineData
f6a72048 1package Gitalist::Controller::Commit;
2
3use Moose;
f6a72048 4use namespace::autoclean;
5
b6ec181b 6BEGIN { extends 'Gitalist::Controller' }
0da7966e 7with 'Gitalist::URIStructure::Commit';
f6a72048 8
9sub base : Chained('/repository/find') PathPart('') CaptureArgs(0) {}
10
b132dce6 11sub 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
20Provides a snapshot of a given commit.
21
22=cut
23
24sub 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
8fd20a28 37=head2 patch
38
39A raw patch for a given commit.
40
41=cut
42
43sub patch : Chained('find') Args(0) {
44 my ($self, $c) = @_;
45 $c->detach('patches', [1]);
46}
47
48=head2 patches
49
50The patcheset for a given commit ???
51
52=cut
53
54sub patches : Chained('find') Args(1) {
55 my ($self, $c, $count) = @_;
56 $count ||= Gitalist->config->{patches}{max};
57 my $commit = $c->stash->{Commit};
58 my $parent = $c->req->param('hp') || undef; # FIXME
59 my $patch = $commit->get_patch( $parent, $count );
60 $c->response->body($patch);
61 $c->response->content_type('text/plain');
62 $c->response->status(200);
63}
64
f6a72048 65__PACKAGE__->meta->make_immutable;