Skip to content

Commit

Permalink
Split out test git user configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
ferki committed Jan 18, 2025
1 parent 1bad3b9 commit 5bf1b21
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions t/scm/git.t
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ else {
plan skip_all => 'Can not find git command';
}

my $git_user_name = 'Rex';
my $git_user_email = '[email protected]';

my $git_environment = {
GIT_CONFIG_GLOBAL => File::Spec->devnull(),
GIT_CONFIG_SYSTEM => File::Spec->devnull(),
Expand Down Expand Up @@ -83,10 +86,7 @@ sub prepare_test_repo {

i_run 'git init', cwd => $directory, env => $git_environment;

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;
configure_git_user($directory);

i_run 'git commit --allow-empty -m commit',
cwd => $directory,
Expand All @@ -112,6 +112,20 @@ sub git_repo_ok {
return;
}

sub configure_git_user {
my $directory = shift;

i_run "git config user.name $git_user_name",
cwd => $directory,
env => $git_environment;

i_run "git config user.email $git_user_email",
cwd => $directory,
env => $git_environment;

return;
}

sub init_test {
my $clone_target_dir = tempdir( CLEANUP => 1 );

Expand Down

0 comments on commit 5bf1b21

Please sign in to comment.