sub blob : Local {
my ( $self, $c ) = @_;
-
+ $c->stash(current_model => 'GitRepos');
+ my $project = $c->stash->{Project};
my $h = $c->req->param('h')
- || $c->model()->hash_by_path($c->req->param('f'))
+ || $project->hash_by_path($c->req->param('hb'), $c->req->param('f'))
|| die "No file or sha1 provided.";
my $hb = $c->req->param('hb')
- || $c->model()->head_hash
+ || $project->head_hash
|| die "Couldn't discern the corresponding head.";
my $filename = $c->req->param('f') || '';
$c->stash(
- blob => $c->model()->get_object($h)->content,
- head => $c->model()->get_object($hb),
+ blob => $project->get_object($h)->contents,
+ head => $project->get_object($hb),
filename => $filename,
# XXX Hack hack hack, see View::SyntaxHighlight
language => ($filename =~ /\.p[lm]$/ ? 'Perl' : ''),
return @ret;
}
- method get_object (Str $sha1) {
+ method get_object (NonEmptySimpleStr $sha1) {
+ unless ( $self->valid_rev($sha1) ) {
+ $sha1 = $self->head_hash($sha1);
+ }
return Object->new(
project => $self,
sha1 => $sha1,
);
}
-
+
# Should be in ::Object
method get_object_mode_string (Gitalist::Git::Object $object) {
return unless $object && $object->{mode};
);
my @out = $self->raw_diff(
- ( $patch ? '--patch-with-raw' : () ),
- $parent, $commit->sha1, @etc
+ \(( $patch ? '--patch-with-raw' : () ),
+ $parent, $commit->sha1, @etc )
);
# XXX Yes, there is much wrongness having parse_diff_tree be destructive.
test('/tree', 'h=145dc3ef5d307be84cb9b325d70bd08aeed0eceb;hb=36c6c6708b8360d7023e8a1649c45bcf9b3bd818');
test('/search', 'h=36c6c6708b8360d7023e8a1649c45bcf9b3bd818&f=&type=commit&text=added');
test('/blobdiff', 'f=file1;h=5716ca5987cbf97d6bb54920bea6adde242d87e6;hp=257cc5642cb1a054f08cc83f2d943e56fd3ebe99;hb=refs/heads/master;hpb=3bc0634310b9c62222bb0e724c11ffdfb297b4ac');
+ test('/blob', 'f=dir1/file2;hb=36c6c6708b8360d7023e8a1649c45bcf9b3bd818');
}
done_testing;