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
20 changes: 18 additions & 2 deletions test/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import platform
import subprocess
import tempfile
from pathlib import Path

Expand All @@ -20,11 +21,26 @@

@pytest.fixture(scope="session", autouse=True)
def git_global_config():
# run-task writes to the global git config, so point it at a real
# (writable) empty file instead of ~/.gitconfig.
# Until https://github.com/taskcluster/taskcluster/issues/6561 we need to
# preserved the safe directories that `run-task` sets to keep tests
# working in CI when workers run subsequent tasks.
existing_safe_dirs = subprocess.run(
["git", "config", "--global", "--get-all", "safe.directory"],
capture_output=True,
text=True,
check=False,
).stdout.splitlines()

fd, path = tempfile.mkstemp(prefix="taskgraph-gitconfig-")
os.close(fd)
os.environ["GIT_CONFIG_GLOBAL"] = path

for entry in existing_safe_dirs:
subprocess.run(
["git", "config", "--global", "--add", "safe.directory", entry],
check=False,
)

yield
del os.environ["GIT_CONFIG_GLOBAL"]
os.unlink(path)
Expand Down
Loading