Skip to content

Commit

Permalink
Ignore global and system git config in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ferki committed Jul 29, 2023
1 parent 577657d commit 1906879
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions t/scm/git.t
Expand Up @@ -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 );
Expand Down Expand Up @@ -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 noreply@rexify.org', cwd => $directory;
i_run 'git config user.name Rex', cwd => $directory, env => $git_environment;
i_run 'git config user.email noreply@rexify.org',
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;
}
Expand All @@ -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;
Expand Down

0 comments on commit 1906879

Please sign in to comment.