1 package Gitalist::Controller::Commit;
4 use namespace::autoclean;
6 BEGIN { extends 'Gitalist::Controller' }
7 with 'Gitalist::URIStructure::Commit';
9 sub base : Chained('/repository/find') PathPart('') CaptureArgs(0) {}
11 sub blob_plain : Chained('find_blob') Does('FilenameArgs') Args() {
14 $c->response->content_type('text/plain; charset=utf-8');
15 $c->response->body(delete $c->stash->{blob});
20 Provides a snapshot of a given commit.
24 sub snapshot : Chained('base') Args() {
25 my ($self, $c, $format) = @_;
27 my @snap = $c->stash->{Repository}->snapshot(
28 sha1 => $c->stash->{Commit}->sha1,
31 $c->response->status(200);
32 $c->response->headers->header( 'Content-Disposition' =>
33 "attachment; filename=$snap[0]");
34 $c->response->body($snap[1]);
39 A raw patch for a given commit.
43 sub patch : Chained('find') Args(0) {
45 $c->detach('patches', [1]);
50 The patcheset for a given commit ???
54 sub 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);
65 __PACKAGE__->meta->make_immutable;