File: 25-revparse.t

package info (click to toggle)
libgit-raw-perl 0.79-7
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 1,448 kB
  • sloc: perl: 5,267; ansic: 182; makefile: 6
file content (50 lines) | stat: -rw-r--r-- 1,238 bytes parent folder | download | duplicates (2)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!perl

use Test::More;

use Git::Raw;
use File::Spec::Functions qw(catfile rel2abs);

my $path = rel2abs(catfile('t', 'test_repo'));
my $repo = Git::Raw::Repository -> open($path);

$repo -> revparse ('HEAD'); # void context
is $repo -> revparse ('HEAD'), 1;
my @revs = $repo -> revparse ('HEAD');
is scalar(@revs), 1;
my $head = shift @revs;
isa_ok $head, 'Git::Raw::Commit';

is $repo -> revparse ('HEAD~..HEAD'), 2;
@revs = $repo -> revparse ('HEAD~..HEAD');
is scalar(@revs), 2;
isa_ok $revs[0], 'Git::Raw::Commit';
isa_ok $revs[1], 'Git::Raw::Commit';
is $revs[1] -> id, $head -> id;

my $prev_head = shift @revs;

@revs = $repo -> revparse('master~..master');
is scalar(@revs), 2;
is $revs[0] -> id, $prev_head -> id;
is $revs[1] -> id, $head -> id;

my @mb = $repo -> revparse('master~...master');
isa_ok $mb[0], 'Git::Raw::Commit';
isa_ok $mb[1], 'Git::Raw::Commit';

is $revs[0] -> id, $mb[0] -> id;
is $revs[1] -> id, $mb[1] -> id;

@revs = $repo -> revparse('@{1}');
is scalar(@revs), 1;
is $revs[0] -> id, $prev_head -> id;

@revs = $repo -> revparse('master@{1}');
is scalar(@revs), 1;
is $revs[0] -> id, $prev_head -> id;

my $nonexistent = eval { $repo -> revparse('nonexistent') };
is $nonexistent, undef;

done_testing;