forked from RexOps/Rex
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ignore global and system git config in tests
- Loading branch information
Showing
1 changed file
with
17 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,9 +26,14 @@ else { | |
plan skip_all => 'Can not find git command'; | ||
} | ||
|
||
my $git_environment = { | ||
GIT_CONFIG_GLOBAL => File::Spec->devnull(), | ||
GIT_CONFIG_SYSTEM => File::Spec->devnull(), | ||
}; | ||
|
||
ok( $git, "Found git command at $git" ); | ||
|
||
my $git_version = i_run 'git version'; | ||
my $git_version = i_run 'git version', env => $git_environment; | ||
ok( $git_version, qq(Git version returned as '$git_version') ); | ||
|
||
my $test_repo_dir = tempdir( CLEANUP => 1 ); | ||
|
@@ -77,12 +82,16 @@ subtest 'clone into existing directory', sub { | |
sub prepare_test_repo { | ||
my $directory = shift; | ||
|
||
i_run 'git init', cwd => $directory; | ||
i_run 'git init', cwd => $directory, env => $git_environment; | ||
|
||
i_run 'git config user.name Rex', cwd => $directory; | ||
i_run 'git config user.email [email protected]', cwd => $directory; | ||
i_run 'git config user.name Rex', cwd => $directory, env => $git_environment; | ||
i_run 'git config user.email [email protected]', | ||
cwd => $directory, | ||
env => $git_environment; | ||
|
||
i_run 'git commit --allow-empty -m commit', cwd => $directory; | ||
i_run 'git commit --allow-empty -m commit', | ||
cwd => $directory, | ||
env => $git_environment; | ||
|
||
return; | ||
} | ||
|
@@ -96,7 +105,9 @@ sub git_repo_ok { | |
"$directory has .git subdirectory" | ||
); | ||
|
||
lives_ok { i_run 'git rev-parse --git-dir', cwd => $directory } | ||
lives_ok { | ||
i_run 'git rev-parse --git-dir', cwd => $directory, env => $git_environment | ||
} | ||
"$directory looks like a git repository now"; | ||
|
||
return; | ||
|