my $repository = $c->stash->{Repository};
my $commit = $c->stash->{Commit};
my $tree_obj = $c->stash->{filename}
- ? $repository->get_object($commit->sha_by_path($c->stash->{filename}))
+ ? $commit->sha_by_path($c->stash->{filename})
: $commit->tree->[0]
;
$c->stash(
);
my $commit = $repository->get_object('HEAD');
- my $file = $repository->get_object($commit->sha_by_path($filename));
+ my $file = $commit->sha_by_path($filename);
my $page = $c->req->param('pg') || 0;
$logargs{skip} = $c->req->param('pg') * $logargs{count}
#'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
$line =~ m/^([0-9]+) (.+) ($SHA1RE)\t/;
my $sha1 = $3;
- return $sha1;
+ return $self->repository->get_object($sha1);
}
method get_patch ( Maybe[NonEmptySimpleStr] $parent_hash?,
sub find_blob : Action {
my ($self, $c) = @_;
my($repo, $object) = @{$c->{stash}}{qw(Repository Commit)};
+
# FIXME - Eugh!
- my $h = $object->isa('Gitalist::Git::Object::Commit')
- ? $object->sha_by_path($c->stash->{filename})
- : $object->isa('Gitalist::Git::Object::Blob')
- ? $object->sha1
- : die "Unknown object type for '${\$object->sha1}'";
+ my $blob;
+ if ($object->isa('Gitalist::Git::Object::Commit')) {
+ $blob = $object->sha_by_path($c->stash->{filename});
+ } elsif ($object->isa('Gitalist::Git::Object::Blob')) {
+ $blob = $object;
+ } else {
+ die "Unknown object type for '${\$object->sha1}'";
+ }
die "No file or sha1 provided."
- unless $h;
- $c->stash(blob => $repo->get_object($h)->content);
+ unless $blob;
+
+ $c->stash(blob => $blob->content);
}
sub blob : Chained('find') Does('FilenameArgs') Args() {
my $obj3 = $proj->get_object($proj->head_hash);
isa_ok($obj3, 'Gitalist::Git::Object::Commit');
-my $hbp_sha1 = $obj3->sha_by_path('dir1/file2');
-my $obj2 = $proj->get_object($hbp_sha1);
+my $obj2 = $obj3->sha_by_path('dir1/file2');
isa_ok($obj2, 'Gitalist::Git::Object::Blob');
is($obj2->type, 'blob', 'sha_by_path obj is a blob');
is($obj2->content, "foo\n", 'sha_by_path obj content is correct');