Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions tests/unit/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import pytest


@pytest.fixture(autouse=True)
def hermetic_git_env(monkeypatch: pytest.MonkeyPatch):
"""Drop Git environment variables inherited from the outer process.

`git commit` runs pre-commit hooks with GIT_INDEX_FILE (and friends) exported,
pointing at the parent repository's index. This fixture prevents Git subprocesses
from reading that index and failing to find objects.
"""

for var in (
"GIT_INDEX_FILE",
"GIT_DIR",
"GIT_WORK_TREE",
"GIT_OBJECT_DIRECTORY",
):
monkeypatch.delenv(var, raising=False)
Loading