Repository navigation
fix(hooks): decline when a worktree has no dependencies - #1095
chappie-daemon wants to merge 1 commit into
Conversation
`git worktree add` never runs `prepare`, so a factory worktree arrives with neither `.husky/_` nor `node_modules`; the `. _/husky.sh` source then aborted every commit with rc 1 before any gate ran. Six tool-call rows across four days were that failure, each paid as a discovery of `--no-verify`. Both hooks now decline when there are no dependencies to lint or test, and source the shim only when it exists. A checkout that can run its gates runs them unchanged - verified in a fresh worktree: commit rc 0 with no deps, and the shim plus `pnpm run lint` still ran once they were present.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
[Medium impact] The change affects commit checks in this repository's developer workflow. Fix the missing-shim path in Findings
|
| # cannot: a checkout without dependencies has no gates to fail. | ||
| [ -d node_modules ] || exit 0 | ||
| _root=$(dirname -- "$0") | ||
| [ -f "$_root/_/husky.sh" ] && . "$_root/_/husky.sh" |
There was a problem hiding this comment.
If node_modules exists but .husky/_/husky.sh does not, pre-commit now runs without stopping on a failed command. This can happen in a worktree with linked dependencies or dependencies installed without prepare. If pnpm run lint fails but the build and tests pass, the hook returns success and allows the commit. Enable set -e after the optional shim or check each command's result explicitly.
| [ -f "$_root/_/husky.sh" ] && . "$_root/_/husky.sh" | |
| [ -f "$_root/_/husky.sh" ] && . "$_root/_/husky.sh" | |
| set -e |
What was wrong
A factory worktree cannot commit.
git worktree adddoes not runprepare, so the new checkout has neither.husky/_nornode_modules, and the first line of both hooks aborts:shexits a non-interactive script when a.fails, so no gate ever runs and the commit never happens. The workaround every agent finds is--no-verify, which skips the gates the hooks exist to enforce.Six tool-call rows across 2026-11-06..09 were this failure, from both the primary and job subagents, all inside
projects/nostream-worktrees/*.What this changes
Both hooks now decline when the checkout has nothing to run, and source the shim only when it exists:
A checkout that can run its gates is unchanged:
pnpm run lint,build:check,test:unitandcommitlintstill run, and still block on failure.Verified in a fresh worktree off this base
node_modules, no.husky/_rc=1, no commitrc=0, commit landsnode_modules+.husky/_presentHOOK-RAN),pnpm run lintexecutesOut of scope
The deeper cause is that a worktree is expected to install before committing. Making
preparerun per worktree would put a full dependency install on every factory job, so declining is the cheaper and more honest behaviour for a checkout with no dependencies: there is nothing for the gates to check against.