Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit test changes my ~/.gitconfig file #229

Open
ding-aling opened this issue Sep 5, 2024 · 0 comments
Open

Unit test changes my ~/.gitconfig file #229

ding-aling opened this issue Sep 5, 2024 · 0 comments

Comments

@ding-aling
Copy link

Hi,
The unit test t/01-repo.t calls
$config -> str('init.defaultBranch', 'main');
which has the side-affect of updating the user's .gitconfig file.
The can be rectified by using the default value which has already been determined in the current code to restore the original value - or absence:

my $config = Git::Raw::Config -> default();  
my $default = $config -> str('init.defaultBranch'); 
$config -> str('init.defaultBranch', 'main');

my $repo = Git::Raw::Repository -> init($native_path, 0);

if (defined $default)    # <-- additional code from here to restore original setting
{
    $config->str('init.defaultbranch', $default);
}
else
{
    $config->delete('init.defaultbranch');
}

Even better would be to extend Git::Raw::Repository -> init to more fully emulate the git init command with support for the --initial-branch=<branch-name> option.

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant