reuse_refs_check: sibling repos beside the MAIN clone for a worktree (R-1114)
gates / gates (push) Successful in 6m43s

FELHOM_WORKSPACE (set by felhom-controller's runner) names where the sibling repos are; the worktree's own
main clone is skipped. Unset: unchanged. Test red-proved both ways.

Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
2026-10-17 09:39:01 +02:00
parent 796c373a3a
commit 0314b8e7cf
3 changed files with 54 additions and 2 deletions
+24
View File
@@ -17,6 +17,7 @@ import shutil
import sys
import tempfile
import unittest
from unittest import mock
SCRIPT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "reuse_refs_check.py")
@@ -119,6 +120,29 @@ class ReuseRefsCheckTest(unittest.TestCase):
self.assertEqual(rc, 0, out)
self.assertIn("cross-repo", out)
# ── R-1114: a worktree outside git/ searches the workspace, never its own main clone ──
def test_worktree_searches_the_workspace_not_its_own_main_clone(self):
ws = os.path.join(self.tmp, "git")
main = os.path.join(ws, "mainrepo")
os.makedirs(os.path.join(main, ".git", "worktrees", "b3"))
write(os.path.join(main, "only", "in", "main.go"), "package in\n")
shared = os.path.join(ws, "felhom.eu")
os.makedirs(os.path.join(shared, ".git"))
write(os.path.join(shared, "scripts", "x.py"), "# gate\n")
wt = os.path.join(self.tmp, "wt", "b3")
write(os.path.join(wt, ".git"), "gitdir: %s\n" % os.path.join(main, ".git", "worktrees", "b3"))
write(os.path.join(wt, "REUSE.md"), "run `felhom.eu/scripts/x.py`\n")
rc, out = self.run_check(wt)
self.assertNotEqual(rc, 0, "without FELHOM_WORKSPACE the worktree's own parent holds no felhom.eu:\n" + out)
with mock.patch.dict(os.environ, {"FELHOM_WORKSPACE": ws}):
rc, out = self.run_check(wt)
self.assertEqual(rc, 0, out)
self.assertNotIn("mainrepo", out.split("siblings searched:")[-1]) # its own main clone is skipped
# a path that exists only in the main clone (deleted in the worktree) must NOT resolve there
write(os.path.join(wt, "REUSE.md"), "see `only/in/main.go`\n")
rc, out = self.run_check(wt)
self.assertNotEqual(rc, 0, out)
def test_non_git_sibling_is_not_searched(self):
plain = os.path.join(self.tmp, "notarepo") # no .git — not a repo, must not resolve
write(os.path.join(plain, "pkg", "x.go"), "package pkg\n")