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->{Repository}->diff(
18 commit => $c->stash->{Commit},
22 sub raw : Chained('find') Does('FilenameArgs') Args() {
24 $c->forward('find_blob');
26 if(-T $c->stash->{blob}) {
27 $c->response->content_type('text/plain; charset=utf-8');
29 my $ft = File::Type->new();
30 $c->response->content_type(
31 File::Type::WebImages::mime_type($c->stash->{blob})
32 || File::Type->new->mime_type($c->stash->{blob})
36 $c->response->body(delete $c->stash->{blob});
41 Provides a snapshot of a given commit.
45 sub snapshot : Chained('find') PathPart('snapshot') Args() {
46 my ($self, $c, $format) = @_;
48 my @snap = $c->stash->{Repository}->snapshot(
49 sha1 => $c->stash->{Commit}->sha1,
52 $c->response->status(200);
53 $c->response->headers->header( 'Content-Disposition' =>
54 "attachment; filename=$snap[0]");
55 $c->response->body($snap[1]);
60 A raw patch for a given commit.
64 sub patch : Chained('find') Args(0) {
66 $c->detach('patches', [1]);
71 The patcheset for a given commit ???
75 sub patches : Chained('find') Args(1) {
76 my ($self, $c, $count) = @_;
77 $count ||= Gitalist->config->{patches}{max};
78 my $commit = $c->stash->{Commit};
79 my $parent = $c->req->param('hp') || undef; # FIXME
80 my $patch = $commit->get_patch( $parent, $count );
81 $c->response->body($patch);
82 $c->response->content_type('text/plain');
83 $c->response->status(200);
86 __PACKAGE__->meta->make_immutable;