You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@magpie.apache.org by po...@apache.org on 2026/06/29 01:28:23 UTC
(magpie) 01/01: fix(tools/dev): scrub location-redirecting git env vars in run-workspace-check.sh
This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch fix/prek-scrub-git-env
in repository https://gitbox.apache.org/repos/asf/magpie.git
commit 0298e7f8636f8a96585fba76d5de86ded8db0f38
Author: Tester <t...@example.com>
AuthorDate: Mon Jun 29 03:27:13 2026 +0200
fix(tools/dev): scrub location-redirecting git env vars in run-workspace-check.sh
Pre-commit runs the workspace-* hooks via this script as a git hook, so git
exports GIT_DIR / GIT_INDEX_FILE / GIT_WORK_TREE pointing at this repo. Member
tests that shell out to git in a throwaway repo (e.g. tools/agent-isolation,
tools/vcs) inherited those and operated on the wrong repository — passing
standalone but failing under `git commit`.
Unset the location-redirecting GIT_* vars at the top of the script so git
resolves each test's repo from its own cwd. The script reads pyproject.toml
via Python, not git, so it needs none of them itself.
Verified: agent-isolation pytest fails with GIT_DIR/GIT_INDEX_FILE set and the
scrub removed; passes (all 21 workspace members) with the scrub.
Generated-by: Claude Code (Opus 4.8)
---
tools/dev/run-workspace-check.sh | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/tools/dev/run-workspace-check.sh b/tools/dev/run-workspace-check.sh
index b2f95e66..07971770 100755
--- a/tools/dev/run-workspace-check.sh
+++ b/tools/dev/run-workspace-check.sh
@@ -66,6 +66,16 @@ CHECK_KEY="$1"
CHECK_CMD="$2"
shift 2
+# Scrub location-redirecting git env vars. When pre-commit runs this script
+# as a git hook, git exports GIT_DIR / GIT_INDEX_FILE / GIT_WORK_TREE (etc.)
+# pointing at *this* repository. Any member test that shells out to `git` in
+# a throwaway repo (e.g. tools/agent-isolation, tools/vcs) would otherwise
+# inherit those and operate on the wrong repository — passing standalone but
+# failing under `git commit`. Unsetting them makes git resolve the repo from
+# each test's own cwd. This script reads pyproject.toml via Python, not git,
+# so it needs none of these itself.
+unset GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE GIT_COMMON_DIR GIT_PREFIX
+
# On Apple Silicon Macs, git ships as x86_64 (Rosetta). Pre-commit hooks
# invoked by git therefore run in an x86_64 context where universal Python
# binaries also run as x86_64, which cannot load arm64-compiled extensions