ci-box: mount the shared clone when the checkout is a git worktree
A hosted job's checkout is a worktree: .git is a file naming a directory in the shared clone. Without that directory git has no repository inside the box, and gitleaks and the tests that list tracked files fail.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
1 file changed,
+7
−0
scripts/ci-box.py+7 −0
Intent
diff --git a/scripts/ci-box.py b/scripts/ci-box.py| index 5f96fd6d..1317fe87 100755 |
| --- a/scripts/ci-box.py |
| +++ b/scripts/ci-box.py |
| @@ -327,6 +327,13 @@ def run(command): |
| "-v", tools + ":" + TRY_BIN + ":ro"] |
| if tool == "docker": |
| args.append("--init") # reaps the orphans the containment tests leave on purpose |
| + # A CI runner checks a branch out as a git worktree: .git is a file |
| + # that names a directory in the shared clone. Mount that clone where |
| + # the file says it is, or git has no repository inside the box. |
| + if os.path.isfile(os.path.join(ROOT, ".git")): |
| + common = git("rev-parse", "--path-format=absolute", "--git-common-dir").stdout.decode().strip() |
| + if common: |
| + args += ["-v", common + ":" + common] |
| for mount in filter(None, os.environ.get("EQUIPO_CI_BOX_MOUNTS", "").split(os.pathsep)): |
| args += ["-v", mount] |
| env = { |