From d21134840adbf18fef2959de14f410dc582ae3db Mon Sep 17 00:00:00 2001 From: Adrian DC Date: Sat, 17 Aug 2024 00:25:55 +0200 Subject: [PATCH] test(conftest): disable 'safe.directory' Git config for container bound sources Details: The git sources folder ownership may be detected as dubious if running in a container with sources mounted to work on fixes and tests, breaking 'test_find_git_project_root' and 'test_get_commits_with_signature' > commitizen.exceptions.GitCommandError: fatal: detected dubious ownership in repository at '...' --- Signed-off-by: Adrian DC --- tests/conftest.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index cc306ac6d..95f3df3b2 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -35,12 +35,19 @@ def git_sandbox(monkeypatch: pytest.MonkeyPatch, tmp_path: Path): gitconfig = tmp_path / ".git" / "config" if not gitconfig.parent.exists(): gitconfig.parent.mkdir() + monkeypatch.setenv("GIT_CONFIG_GLOBAL", str(gitconfig)) + r = cmd.run(f"git config --file {gitconfig} user.name {SIGNER}") assert r.return_code == 0, r.err r = cmd.run(f"git config --file {gitconfig} user.email {SIGNER_MAIL}") assert r.return_code == 0, r.err - cmd.run("git config --global init.defaultBranch master") + + r = cmd.run(f"git config --file {gitconfig} safe.directory '*'") + assert r.return_code == 0, r.err + + r = cmd.run("git config --global init.defaultBranch master") + assert r.return_code == 0, r.err @pytest.fixture