Skip to content

Commit 89978e1

Browse files
committed
test: fix git_sandbox for git<2.33
for old git like git-2.30 the tests broke my ~/.gitconfig file and created thousands of `name=GitHub` lines Signed-off-by: apkawa <apkawa@gmail.com>
1 parent c3d2c91 commit 89978e1

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

tests/conftest.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,14 @@ def git_sandbox(monkeypatch: pytest.MonkeyPatch, tmp_path: Path):
2323
monkeypatch.delenv(var)
2424

2525
# Define a dedicated temporary git config
26-
monkeypatch.setenv("GIT_CONFIG_GLOBAL", str(tmp_path / "gitconfig"))
27-
cmd.run(f"git config --global user.name {SIGNER}")
28-
cmd.run(f"git config --global user.email {SIGNER_MAIL}")
26+
gitconfig = tmp_path / ".git" / "config"
27+
if not gitconfig.parent.exists():
28+
gitconfig.parent.mkdir()
29+
monkeypatch.setenv("GIT_CONFIG_GLOBAL", str(gitconfig))
30+
r = cmd.run(f"git config --file {gitconfig} user.name {SIGNER}")
31+
assert r.return_code == 0, r.err
32+
r = cmd.run(f"git config --file {gitconfig} user.email {SIGNER_MAIL}")
33+
assert r.return_code == 0, r.err
2934

3035

3136
@pytest.fixture(scope="function")

0 commit comments

Comments
 (0)