test: fix test failure in case of different default branch (#6857)

* test: fix test failure in case of different default branch

When the git config has set global `init.defaultBranch` different than master,
a few test cases were failing.
Currently, the test case is assuming the default branch to be set as
master.

This commit will introduce **initial_branch** option to git init call
which will ensure *master* branch is used as default for out test cases.

Set default git branch to main for test CI

Since main is going to be new default branch, it will let the test case
handle the scenario where default branch is set other than master.

Introduce isolation for git configuration

Co-authored-by: Saugat Pachhai (सौगात) <[email protected]>
This commit is contained in:
Amrit Ghimire
2022-01-07 11:13:04 +05:45
committed by GitHub
co-authored by Saugat Pachhai
parent ec3600eb8e
commit 44a1146915
10 changed files with 66 additions and 66 deletions
+3 -6
View File
@@ -4,6 +4,7 @@ from unittest.mock import patch
import pytest
from funcy import first
from scmrepo.git import Git
from dvc.config import NoRemoteError
from dvc.dvcfile import Dvcfile
@@ -268,9 +269,7 @@ def test_pull_wildcard_imported_directory_stage(tmp_dir, dvc, erepo_dir):
def test_push_wildcard_from_bare_git_repo(
tmp_dir, make_tmp_dir, erepo_dir, local_cloud
):
import git
git.Repo.init(os.fspath(tmp_dir), bare=True)
Git.init(tmp_dir.fs_path, bare=True).close()
erepo_dir.add_remote(config=local_cloud.config)
with erepo_dir.chdir():
@@ -381,9 +380,7 @@ def test_pull_no_rev_lock(erepo_dir, tmp_dir, dvc):
def test_import_from_bare_git_repo(
tmp_dir, make_tmp_dir, erepo_dir, local_cloud
):
import git
git.Repo.init(os.fspath(tmp_dir), bare=True)
Git.init(tmp_dir.fs_path, bare=True).close()
erepo_dir.add_remote(config=local_cloud.config)
with erepo_dir.chdir():