oficina / equipo Public

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>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 2b461949e0b4a6b978f39df4e2782df93ab62615 parent dfc5830
1 file changed, +7 −0
  • scripts/ci-box.py +7 −0
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 = {