Repository navigation
fix(hooks): compare repositories, not containment, for the sibling exemption - #16
Merged
Merged
Conversation
…emption The sibling-repo exemption inverted in exactly the session shape it exists to serve. worktreeRoot() falls back to the project dir when `git rev-parse` fails, so a session rooted at the multi-root workspace folder — which is not itself a repository — takes ROOT to be that folder. Every sibling checkout then sits *under* ROOT, the containment test read each one as "inside this worktree", and both git rules fired on precisely the cross-repo work the exemption was written to allow. A subagent doing the rules migration hit this and had to route every command through `env -C <repo> git …` to get anything done. Compare repositories instead: resolve the target's own git top-level and the session's, and exempt when they differ. Two cases fall out cleanly — a session root that is not a repository has no "this repo" for the rules to be about, so everything is a sibling; and a path outside any repository is nothing the rules have an opinion on. Verified against all three session shapes: from the workspace root both `cd <sibling> && git` and `git -C <sibling>` now pass, while same-repo `git -C` and `cd <subdir> && git` still deny from inside a repo. Co-Authored-By: Claude Opus 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
block-wrong-bashcompared directory containment, which inverts in a multi-root workspace session — every sibling repo read as "inside this worktree" and both git rules fired on the cross-repo work the exemption exists to allowChanges
workflow/hooks/block-wrong-bash.mjs—gitTopLevel()helper;targetsSiblingRepo()rewritten, with the failure mode documented in place so it is not re-simplified backTest results
node --checkcleancd <sibling> && git statusgit -C <sibling> statuscd <sibling> && git statusgit -C <same-repo>/docs statuscd docs && git logNotes for reviewer
Found by the subagent doing the SahajCloud rules migration — it could not run git in a sibling repo at all and had to work around it with
env -C <repo> git …, which matches neither regex. That workaround is worth knowing about independently: it is the clean way to run git in another repo without tripping either rule.Two edge cases are now explicit rather than accidental: a session root that is not a repository (every target is a sibling — the workspace case) and a target outside any repository (the rules have nothing to say about it).