Skip to content

Commit

Permalink
test(conftest): disable 'safe.directory' Git config for container bou…
Browse files Browse the repository at this point in the history
…nd 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 <radian.dc@gmail.com>
  • Loading branch information
AdrianDC authored and Lee-W committed Nov 16, 2024
1 parent 9aa3076 commit 9c891d6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9c891d6

Please sign in to comment.