chore: migrate from husky to native git 2.54 config-based hooks#3415
Open
jevonearth wants to merge 1 commit into
Open
chore: migrate from husky to native git 2.54 config-based hooks#3415jevonearth wants to merge 1 commit into
jevonearth wants to merge 1 commit into
Conversation
Replace husky with Git's built-in [hook "..."] config mechanism (Git 2.54+). The pre-commit hook now lives in .githooks.config, wired into .git/config via include.path by scripts/setup-hooks.sh, which runs as the prepare script on npm install. - Removes husky devDependency (-1 dep, zero transitives; husky 9 has no runtime deps). - Script warns and exits 0 on Git < 2.54 so npm ci still passes on older runners (e.g. ubuntu-latest currently ships Git 2.53). - Only unsets core.hooksPath if it points at the old .husky/_ path, preserving any custom hook directory the contributor has set. - Idempotent: repeat runs don't duplicate the include.path entry.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3415 +/- ##
=======================================
Coverage 80.03% 80.03%
=======================================
Files 250 250
Lines 14928 14928
Branches 3682 3682
=======================================
Hits 11948 11948
Misses 2980 2980 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
Replaces husky with Git's built-in config-based hooks (Git 2.54+, release notes). The single
pre-commithook (npm run precommit) now lives in a tracked.githooks.config, wired into.git/configviainclude.pathby apreparescript.huskydevDependency (net -1 package; husky 9 has zero transitives)..husky/_/husky.shshell-sourcing dance.Behavior details
Old Git handling.
scripts/setup-hooks.shwarns to stderr and exits 0 on Git < 2.54 instead of failing. Needed becauseubuntu-latestcurrently ships Git 2.53, sonpm ciwould otherwise fail in CI before build/test. Contributors on old Git see a loud message explaining why hooks won't run.core.hooksPathsafety. Only unset when it equals.husky/_(the old husky pointer). Any other value — including a contributor's intentional custom hook directory — is left alone.Idempotent. Repeat
npm installruns don't duplicate theinclude.pathentry.Tarball/CI-without-.git safety. If there's no
.gitdirectory, the script exits 0 cleanly.Verify
Disable locally without editing the config:
git config --local hook.precommit.enabled falseTest plan
npm installwiresinclude.path;git hook list pre-commitshowsprecommitprecommit(lint-staged fanout), blocks on failurenpm installrun does not duplicateinclude.pathcore.hooksPath=.husky/_, script unsets itcore.hooksPath=/some/user/path, script leaves it alone.gitpresent → script exits 0ubuntu-latest(Git 2.53) —prepareshould warn + exit 0, not fail