Make diff action work nicely
[catagits/Gitalist.git] / lib / Gitalist / Controller / Fragment / Commit.pm
CommitLineData
0da7966e 1package Gitalist::Controller::Fragment::Commit;
2use Moose;
3use namespace::autoclean;
4
5BEGIN { extends 'Catalyst::Controller' }
6with 'Gitalist::URIStructure::Commit';
7
8sub base : Chained('/fragment/repository/find') PathPart('') CaptureArgs(0) {}
9
493327c8 10after diff => sub {
11 my ($self, $c) = @_;
12 my $commit = $c->stash->{Commit};
13 my($tree, $patch) = $c->stash->{Repository}->diff(
14 commit => $commit,
15 parent => $c->req->param('hp') || undef,
16 patch => 1,
17 );
18 $c->stash(
19 diff_tree => $tree,
20 diff => $patch,
21 # XXX Hack hack hack, see View::SyntaxHighlight
22 blobs => [map $_->{diff}, @$patch],
23 language => 'Diff',
24 );
25
26 $c->forward('View::SyntaxHighlight')
27 unless $c->stash->{plain};
28};
29
0da7966e 30__PACKAGE__->meta->make_immutable;