1 package Gitalist::Controller::Ref;
4 use namespace::autoclean;
6 BEGIN { extends 'Gitalist::Controller' }
7 with 'Gitalist::URIStructure::Ref';
10 use File::Type::WebImages ();
12 sub base : Chained('/repository/find') PathPart('') CaptureArgs(0) {}
17 $c->stash->{diff_tree} = ( $c->stash->{Commit}->diff )[0];
20 sub raw : Chained('find') Does('FilenameArgs') Args() {
22 $c->forward('find_blob');
24 if(!Gitalist::Utils::is_binary($c->stash->{blob})) {
25 $c->response->content_type('text/plain; charset=utf-8');
27 my $ft = File::Type->new();
28 $c->response->content_type(
29 File::Type::WebImages::mime_type($c->stash->{blob})
30 || File::Type->new->mime_type($c->stash->{blob})
34 $c->response->body(delete $c->stash->{blob});
39 Provides a snapshot of a given commit.
43 sub snapshot : Chained('find') PathPart('snapshot') Args() {
44 my ($self, $c, $format) = @_;
46 my @snap = $c->stash->{Repository}->snapshot(
47 sha1 => $c->stash->{Commit}->sha1,
50 $c->response->status(200);
51 $c->response->headers->header( 'Content-Disposition' =>
52 "attachment; filename=$snap[0]");
53 $c->response->body($snap[1]);
58 A raw patch for a given commit.
62 sub patch : Chained('find') Args(0) {
64 $c->detach('patches', [1]);
69 The patcheset for a given commit ???
73 sub patches : Chained('find') Args(1) {
74 my ($self, $c, $count) = @_;
75 $count ||= Gitalist->config->{patches}{max};
76 my $commit = $c->stash->{Commit};
77 my $parent = $c->req->param('hp') || undef; # FIXME
78 my $patch = $commit->get_patch( $parent, $count );
79 $c->response->body($patch);
80 $c->response->content_type('text/plain');
81 $c->response->status(200);
84 __PACKAGE__->meta->make_immutable;