fix(hooks): install Entire into husky user hooks#1778
Open
suhaanthayyil wants to merge 1 commit into
Open
Conversation
Husky regenerates .husky/_ on npm prepare, which previously clobbered Entire's wrappers mid-turn so later commits lost Entire-Checkpoint trailers. Install into the parent .husky/ user-hook directory that husky's stubs invoke, so mid-turn commits keep trailers after prepare. Fixes #784
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates Entire’s git-hook installation logic to be Husky v9–safe by installing managed hooks into Husky’s user hook directory (the parent of core.hooksPath=.husky/_) so Husky/npm prepare regenerations of .husky/_ don’t clobber Entire’s wrappers mid-session (fixing the multi-commit trailer loss described in #784).
Changes:
- Detect Husky v9’s
core.hooksPathshape (.../_with dispatcher_/h) and install Entire-managed hooks into the parent user-hook directory. - Migrate legacy Entire wrappers out of the regenerable Husky-owned
_directory, restoring backups or writing Husky forwarding stubs as needed. - Update hook-manager warnings to emit a Husky-specific advisory note when the Husky-safe install path is active, and add unit + integration coverage for the mid-turn “husky prepare” scenario.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| cmd/entire/cli/strategy/hooks.go | Adds Husky-safe install directory selection, legacy migration/cleanup, and updated installation/removal detection logic. |
| cmd/entire/cli/strategy/hooks_test.go | Updates/extends unit tests for Husky install behavior, migration, and stubs surviving simulated prepare. |
| cmd/entire/cli/strategy/hook_managers.go | Adjusts Husky warning output to a Note when hooks are installed in the Husky-safe user-hook dir. |
| cmd/entire/cli/strategy/hook_managers_test.go | Updates tests for the new Husky-safe Note vs Warning behavior and hooksPath detection. |
| cmd/entire/cli/integration_test/hook_overwrite_husky_test.go | Adds an integration test reproducing the mid-turn Husky regenerate case and asserting trailers persist across commits. |
Comment on lines
+212
to
225
| // huskyForwardingStubsPresent reports whether each managed hook has a | ||
| // non-Entire stub in the husky-owned hooks directory (so git → `_` → parent). | ||
| func huskyForwardingStubsPresent(hooksDir string) bool { | ||
| for _, hook := range gitHookNames { | ||
| data, err := os.ReadFile(filepath.Join(hooksDir, hook)) //nolint:gosec // path from constants | ||
| if err != nil { | ||
| return false | ||
| } | ||
| if strings.Contains(string(data), entireHookMarker) { | ||
| return false | ||
| } | ||
| } | ||
| return true | ||
| } |
Comment on lines
+426
to
+428
| if installDir != hooksDir { | ||
| fmt.Println(" Installed into .husky/ (survives husky/npm prepare)") | ||
| } |
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.
Trail: https://entire.io/gh/entireio/cli/trails/876
https://entire.io/gh/entireio/cli/trails/876
What: Install Entire git hooks into husky's user-hook directory (parent of
core.hooksPath=.husky/_) instead of into regenerable.husky/_.Why / how it helps:
npm install/huskyprepare rewrites.husky/_mid-turn and previously removed Entire's wrappers, so later commits in the same turn silently lostEntire-Checkpointtrailers (Fixes #784). User hooks under.husky/survive prepare, so mid-turn commits keep trailers without per-tool-hook recovery.How:
core.hooksPathis a husky_dir with thehdispatcher, write managed hooks to the parent user-hook dir and leave_stubs alone_(restore.pre-entireor write forwarding stubs)IsGitHookInstalledrequires forwarding stubs so EnsureSetup can heal a broken husky layoutTesting / verification:
npx husky→ commit2 trailer (same turn)hookInstallDirhusky redirect fails unit + integration testsgo test ./cmd/entire/cli/strategy/green (806)go test -tags=integration ./cmd/entire/cli/integration_test/ -run TestHusky_MidTurnPrepare|TestHookOverwrite_MidTurngreenmise run fmt+mise run lint0 issues on committed treeMade with Cursor