mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-16 02:21:46 +04:00
change the HOME for git commands to avoid using the user git configuration
This commit is contained in:
parent
9e193f7fc8
commit
5b472b30eb
2 changed files with 10 additions and 5 deletions
|
|
@ -39,6 +39,11 @@ def tempdir_factory(tmpdir):
|
|||
yield TmpdirFactory()
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def setup_git(monkeypatch, tmpdir):
|
||||
# we should not use user configuration
|
||||
monkeypatch.setenv('HOME', tmpdir)
|
||||
|
||||
@pytest.yield_fixture
|
||||
def in_tmpdir(tempdir_factory):
|
||||
path = tempdir_factory.get()
|
||||
|
|
@ -67,7 +72,7 @@ def _make_conflict():
|
|||
|
||||
|
||||
@pytest.yield_fixture
|
||||
def in_merge_conflict(tempdir_factory):
|
||||
def in_merge_conflict(tempdir_factory, setup_git):
|
||||
path = make_consuming_repo(tempdir_factory, 'script_hooks_repo')
|
||||
with cwd(path):
|
||||
open('dummy', 'a').close()
|
||||
|
|
@ -82,7 +87,7 @@ def in_merge_conflict(tempdir_factory):
|
|||
|
||||
|
||||
@pytest.yield_fixture
|
||||
def in_conflicting_submodule(tempdir_factory):
|
||||
def in_conflicting_submodule(tempdir_factory, setup_git):
|
||||
git_dir_1 = git_dir(tempdir_factory)
|
||||
git_dir_2 = git_dir(tempdir_factory)
|
||||
with cwd(git_dir_2):
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ def test_get_root_not_git_dir(tempdir_factory):
|
|||
git.get_root()
|
||||
|
||||
|
||||
def test_get_staged_files_deleted(tempdir_factory):
|
||||
def test_get_staged_files_deleted(tempdir_factory, setup_git):
|
||||
path = git_dir(tempdir_factory)
|
||||
with cwd(path):
|
||||
open('test', 'a').close()
|
||||
|
|
@ -114,7 +114,7 @@ def test_parse_merge_msg_for_conflicts(input, expected_output):
|
|||
assert ret == expected_output
|
||||
|
||||
|
||||
def test_get_changed_files(in_tmpdir):
|
||||
def test_get_changed_files(in_tmpdir, setup_git):
|
||||
cmd_output('git', 'init', '.')
|
||||
cmd_output('git', 'commit', '--allow-empty', '-m', 'initial commit')
|
||||
open('a.txt', 'a').close()
|
||||
|
|
@ -143,7 +143,7 @@ def test_zsplit(s, expected):
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
def non_ascii_repo(tmpdir):
|
||||
def non_ascii_repo(tmpdir, setup_git):
|
||||
repo = tmpdir.join('repo').ensure_dir()
|
||||
with repo.as_cwd():
|
||||
cmd_output('git', 'init', '.')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue