forked from acme/git-pureperl
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path09_util.t
68 lines (57 loc) · 1.4 KB
/
09_util.t
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!perl
use strict;
use warnings;
use Test::More;
use Git::PurePerl;
use Path::Class;
use Git::PurePerl::Util qw( find_git_dir current_git_dir );
foreach my $directory (qw(test-project test-project-packs test-project-packs2))
{
my $dir = dir($directory);
my $gd = find_git_dir( dir($directory) );
is(
$gd->absolute->stringify,
dir($directory)->subdir('.git')->absolute->stringify,
"Correctly resolves an .git from a repo( $directory )"
);
}
foreach my $directory (
qw(
test-util/deep
test-util/deep/.git
test-util/deep/stage1
test-util/deep/stage1/stage2/
)
)
{
is(
find_git_dir( dir($directory) )->absolute->stringify,
dir('test-util/deep/.git')->absolute->stringify,
"finding .git dirs works at all tree levels ( $directory )"
);
}
foreach my $directory (
qw(
test-util/bare
test-util/bare/info
test-util/bare/objects
test-util/bare/refs
test-util/bare/refs/heads
)
)
{
is(
find_git_dir( dir($directory) )->absolute->stringify,
dir('test-util/bare')->absolute->stringify,
"finding bare dirs works at all tree levels ( $directory )"
);
}
use Cwd qw( getcwd );
my $old_dir = getcwd;
chdir "test-util/deep/stage1";
is(
current_git_dir()->absolute->stringify,
dir('.')->parent->subdir('.git')->absolute->stringify,
"Can work with CWD"
);
done_testing;