Skip to content

Unit test changes my ~/.gitconfig file #229

@ding-aling

Description

@ding-aling

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions