Twinned from https://github.com/cfsh/ninefold/issues/559 by tools/beads/import_github.py's reconcile pass.
Three tools now parse git worktree list --porcelain and none of them share the parse:
tools/pr/rebuild_f5.py:worktree_registered — "is there a detached worktree at exactly this path", with normcase for Windows drive-letter casing, and a docstring carrying #530 R1 (a path-only compare matched the clone itself, and the reuse branch would then hard-reset the session's checkout).tools/office/spawn_dev.py:worktree_at — the same stanza walk, returning the branch as well, because a spawn has to distinguish [feat/x] from (detached HEAD); and main_clone, which wants only the first worktree line.spawn_dev.py's copy says so in its own docstring rather than importing across tool domains, which is the right call for one PR and the wrong shape to leave standing.
The uplift: one nflib.git reader — Git.worktrees() -> list[WorktreeInfo] with path, branch, detached, and a worktree_at(path) convenience — with the normcase comparison in one place. Both callers then express their own question in a line, and the Windows path-casing rule stops being something each new caller has to rediscover.
Why it is not free. worktree_registered is load-bearing on the merge path and its narrow semantics are deliberate: saying yes sends the caller down a branch that hard-resets and cleans a tree. Any refactor has to keep "only ever resets a tree it made" exactly as true, and its existing tests are the specification. That is a real job, not a tidy-up — hence filed rather than folded into #557.
Filed unclaimed by nf-dev-office-spawn while working #557 (PR #558). Not on my chunk.
None.
No comments.