Fixed src and dst in diff data for files that had been added/deleted/etc.
[catagits/Gitalist.git] / lib / Gitalist / Controller / Ref.pm
CommitLineData
2980657b 1package Gitalist::Controller::Ref;
f6a72048 2
3use Moose;
f6a72048 4use namespace::autoclean;
5
b6ec181b 6BEGIN { extends 'Gitalist::Controller' }
2980657b 7with 'Gitalist::URIStructure::Ref';
f6a72048 8
9sub base : Chained('/repository/find') PathPart('') CaptureArgs(0) {}
10
ae36e02c 11after commit => sub {
12 my($self, $c) = @_;
13
14 $c->stash->{diff_tree} = ($c->stash->{Repository}->diff(
15 commit => $c->stash->{Commit},
16 ))[0];
17};
18
ca06a177 19sub raw : Chained('find') Does('FilenameArgs') Args() {
b132dce6 20 my ($self, $c) = @_;
ca06a177 21 $c->forward('find_blob');
b132dce6 22
23 $c->response->content_type('text/plain; charset=utf-8');
24 $c->response->body(delete $c->stash->{blob});
25}
26
27=head2 snapshot
28
29Provides a snapshot of a given commit.
30
31=cut
32
d423d020 33sub snapshot : Chained('find') PathPart('snapshot') Args() {
b132dce6 34 my ($self, $c, $format) = @_;
35 $format ||= 'tgz';
36 my @snap = $c->stash->{Repository}->snapshot(
37 sha1 => $c->stash->{Commit}->sha1,
38 format => $format
39 );
40 $c->response->status(200);
41 $c->response->headers->header( 'Content-Disposition' =>
42 "attachment; filename=$snap[0]");
43 $c->response->body($snap[1]);
44}
45
8fd20a28 46=head2 patch
47
48A raw patch for a given commit.
49
50=cut
51
52sub patch : Chained('find') Args(0) {
53 my ($self, $c) = @_;
54 $c->detach('patches', [1]);
55}
56
57=head2 patches
58
59The patcheset for a given commit ???
60
61=cut
62
63sub patches : Chained('find') Args(1) {
64 my ($self, $c, $count) = @_;
65 $count ||= Gitalist->config->{patches}{max};
66 my $commit = $c->stash->{Commit};
67 my $parent = $c->req->param('hp') || undef; # FIXME
68 my $patch = $commit->get_patch( $parent, $count );
69 $c->response->body($patch);
70 $c->response->content_type('text/plain');
71 $c->response->status(200);
72}
73
f6a72048 74__PACKAGE__->meta->make_immutable;