1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
#!perl
use Test::More;
use Git::Raw;
use Cwd qw(abs_path);
my $path = abs_path('t/test_repo');
my $repo = Git::Raw::Repository -> open($path);
my @revs = $repo -> revparse ('HEAD');
is scalar(@revs), 1;
my $commit = shift @revs;
isa_ok $commit, 'Git::Raw::Commit';
my $annotated = $commit -> annotated;
isa_ok $annotated, 'Git::Raw::AnnotatedCommit';
is $commit -> id, $annotated -> id;
is $commit -> id , "$annotated";
my $head = $repo -> head;
isa_ok $head, 'Git::Raw::Reference';
$annotated = $head -> annotated_commit;
isa_ok $annotated, 'Git::Raw::AnnotatedCommit';
is $commit -> id, $annotated -> id;
my $annotated2 = Git::Raw::AnnotatedCommit -> lookup($repo, $commit -> id);
isa_ok $annotated2, 'Git::Raw::AnnotatedCommit';
is $annotated2 -> id, $annotated -> id;
my $annotated3 = Git::Raw::AnnotatedCommit -> lookup($repo, '1' x 40);
ok (!defined ($annotated3));
done_testing;
|