fix(hook): tolerate untracked specs/INDEX.md + e2e suite - #17
Merged
Conversation
Second real-user pre-commit-hook bug surfaced on `sensor-sender`: checking out a branch that predates the first `regen` (or a fresh init pre-regen) carried `.zettelgeist.yaml` but had no `specs/INDEX.md` in its history, so the hook's `regen --check` errored with `specs/INDEX.md is missing` and blocked every commit on the branch. Fix: HOOK_BLOCK gains a second pre-flight — git ls-files --error-unmatch specs/INDEX.md >/dev/null 2>&1 || exit 0 If the index file isn't tracked on the current branch there's nothing to be stale about, and the hook exits 0. Re-run `install-hook` to update existing hooks (they pick up the new block via marker-region replacement, no config change needed). Add an end-to-end pre-commit suite under packages/git-hook/tests that spins up real git repos, installs the hook through the same code path users hit, and drives `git commit` through five states: 1. non-zg repo → commit passes; CLI not invoked 2. zg repo, INDEX.md not in HEAD → commit passes; CLI not invoked 3. zg repo, INDEX.md in HEAD + check passes → commit passes; CLI invoked 4. zg repo, INDEX.md in HEAD + check fails → commit blocked; CLI invoked 5. checkout to a pre-INDEX branch + commit → commit passes; CLI not invoked The CLI is stubbed with a small `zettelgeist` shell shim on PATH so we can deterministically drive both the success-path and the failure-path and assert pre-flight reachability via a touched marker file. Tests (1) and (5) regression-guard the two real bugs users have hit; the others pin the "actually-stale state must still block" invariant the hook exists for.
morrieinmaas
added a commit
that referenced
this pull request
Jun 3, 2026
Carries the hook fix from #17 (tolerate branches without tracked specs/INDEX.md) via the @zettelgeist/git-hook workspace dep. Already published to Open VSX as morrieinmaas.zettelgeist@0.4.3; MS Marketplace gets zettelgeist-msm-0.4.3.vsix uploaded manually.
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
Second real-user pre-commit-hook bug surfaced on
sensor-sender(apple-updates branch): a back-in-time checkout had.zettelgeist.yamlin its history but nospecs/INDEX.md, so the hook'sregen --checkhard-errored withspecs/INDEX.md is missingand blocked every commit on that branch.Fix: HOOK_BLOCK gains a second pre-flight that exits 0 when the index file isn't tracked on the current branch. Nothing to be stale about ⇒ nothing to enforce. Re-run
install-hookto update existing hooks (they pick up the new block via the existing marker-region replacement).Plus an end-to-end pre-commit suite that would have caught both this and the prior non-zg bug. The suite spins up real git repos and drives
git committhrough five states using a stub CLI on PATH:(1) and (5) regression-guard the two real bugs; (3) and (4) pin the "actually-stale state must still block" invariant the hook exists for.
Changes
packages/git-hook/src/install-hook.ts— second pre-flight inHOOK_BLOCK:git ls-files --error-unmatch specs/INDEX.md >/dev/null 2>&1 || exit 0.packages/git-hook/tests/install-hook.test.ts— unit assertion the new guard string is present.packages/git-hook/tests/pre-commit-e2e.test.ts— new e2e suite (5 cases)..changeset/hook-skips-when-index-not-tracked.md— cli patch.Workaround for currently-stuck users (pre-merge)
Run
zettelgeist regenon the stuck branch — that materializesspecs/INDEX.md, then commits pass. Orrm .git/hooks/pre-commitand reinstall after upgrading.Test plan
pnpm -r typecheck— cleanpnpm -r test— all 9 packages, all greenpnpm conformance— 46 fixtures