Repository navigation
fix(hook): persist selected config in commit-message hooks - #417
Merged
Merged
Conversation
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.
Installed commit-message hooks always read
.charter/config.json, even when CI usesvalidate --config <dir>. Persist the config selection supplied tohook install --commit-msg --config <dir>so the real hook enforces that policy rather than a different default policy.Relative selections are resolved from the installation directory and recorded relative to Git's worktree root; absolute selections remain absolute. The shell quotes the path as data and passes it to Node after
--, including spaces, apostrophes, shell substitutions, and leading dashes. No user-supplied path is interpolated into JavaScript. Reinstallation updates the selection deterministically, managed legacy hooks upgrade, and unmanaged hooks remain untouched unless the existing force option is supplied.The default config path, trailer-policy semantics, missing-config/no-Node warning-and-skip behavior, and #400's printed Claude event are retained. A missing or malformed selected file names that path in the diagnostic and never falls back to
.charter/config.json. The docs explain the missing-file behavior. HIGH-risk local classification remains the separate #342 decision.Closes #341.
This branch includes reviewed PR #412 (
1e9d82be6f4291c8ecec82c52a1f5522c2509a92) as a prerequisite because both issues changehook.ts. The issue-only comparison is against that commit; the PR targets main so required CI runs. Preserve prerequisite ancestry when merging after explicit approval.Validation in an isolated worktree, Windows Node 24.19.0 / pnpm 9.15.9:
pnpm run build, andpnpm run typecheck: pass.pnpm exec vitest run packages/cli/src/__tests__/hook-config.test.ts packages/cli/src/__tests__/hook.test.ts packages/cli/src/__tests__/hook-claude-local.test.ts packages/cli/src/__tests__/hook-pm.test.ts: 141/141 pass. Twelve new real-Git tests cover strict/disabled custom policy vs opposing default, valid/missing/malformed selections, absolute and subdirectory-relative paths, shell-sensitive and leading-dash paths, reinstall/default restore, legacy upgrades, unmanaged preservation/force, and actual CLI global--configplumbing.pnpm run docs:check: pass (optional docs-sync config absent; papers-lint passed).pnpm run test: 1,951 passed, five failed, including one new real-Git fixture exceeding its 5-second timeout under concurrent load. Twelve external-process tests now use a bounded 30-second timeout consistent with existing hook tests; assertions are unchanged. Focused rerun: 141/141 pass. Final full suite: 1,952 passed and only the four known Windows baseline failures (1,956 total). Log: .cache/issue-341-full-tests-final.log.Main CI currently fails its dependency audit. PR #413 contains the separately approved major-version Zod migration plus #404's compatible repairs and passes Linux CI; this PR does not suppress or weaken any gate. No merge, tag/main push, publication, deployment, production-data change, repository setting change, or remote branch deletion performed.
Confirmed review finding corrected
Normalize only the native platform separator when serializing the selected config path. Literal backslashes in POSIX directory names remain data; Windows path separators are still normalized for the shell. Two real-hook POSIX regression cases cover relative and absolute selections and reinstall stability.