fix: install lefthook hooks at repo level, not a global core.hooksPath - #2074
Merged
Merged
Conversation
Marking lefthook as a trusted dependency let its postinstall run `lefthook install -f` on every `bun install`. The `-f` forces installation into whatever core.hooksPath resolves to, so for anyone with a global `core.hooksPath` set, it overwrote their global hooks (backing them up as .mintbak) and made these hooks run in every repository on the machine. Remove lefthook from trustedDependencies so bun no longer runs that forced install, and add a repo postinstall that runs `lefthook install` without -f. Without a global hooksPath it installs into the repo's own .git/hooks as before; with one set, lefthook safely declines instead of overwriting it, and the guard keeps install from failing.
Contributor
Greptile SummaryThis PR prevents Lefthook's forced dependency postinstall from overwriting external Git hook directories.
Confidence Score: 4/5The PR appears safe to merge, with a non-blocking gap for contributors who install dependencies through the documented app-local workflow. Root installs avoid modifying external Git hook directories as intended, but app-local installs no longer invoke any Lefthook installer and therefore silently omit repository hooks. Files Needing Attention: packages/browseros-agent/apps/app/package.json Important Files Changed
Prompt To Fix All With AI### Issue 1
packages/browseros-agent/apps/app/package.json:113-115
**App-local installs omit hooks**
The documented `apps/app`-local `bun install` path does not run the new workspace-root `postinstall`; removing Lefthook from this package's trusted dependencies therefore leaves those contributors without the repository's commit-message, formatting, and branch-name hooks.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "fix: install lefthook hooks at repo leve..." | Re-trigger Greptile |
Contributor
❌ Tests failed — 4/2467 failed
Failed tests
|
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.
Problem
bun installwas overwriting a developer's global git hooks. On a machine with a globalcore.hooksPathconfigured, runningbun installreplaced the hooks in that global directory with this project's lefthook hooks (backing up the originals as.mintbak), which then made these hooks run in every repository on the machine.Root cause
lefthookwas listed intrustedDependencies, which lets bun run thelefthookpackage'spostinstall. That postinstall runs:The
-fflag means "proceed even if core.hooksPath is set". So instead of installing into the repo's own.git/hooks, it force-installs into whatevercore.hooksPathresolves to. When a developer has a globalcore.hooksPath, that is their global hooks directory, and it gets overwritten on every install.Without
-f,lefthook installalready does the right thing: it declines and prints guidance whencore.hooksPathpoints somewhere external, rather than clobbering it.Fix
lefthookfromtrustedDependencies(in the monorepo root and inapps/app) so bun no longer runs the forcedlefthook install -f.postinstallthat runslefthook installwithout-f:core.hooksPathset (the common case): installs into the repo's own.git/hooks, exactly as before.core.hooksPathset: lefthook declines instead of overwriting it; the|| trueguard keepsbun installfrom failing.Net effect: hooks are still installed automatically at the repo level, and the project can no longer touch a contributor's global hooks.
Validation
package.jsonfiles parse as valid JSON.lefthook installwith-fwrites into an externalcore.hooksPath; without-fit refuses and leaves it untouched (exit 1, guarded to 0 by|| true).core.hooksPath: the new postinstall command leaves the global hooks directory byte-for-byte untouched.bun installruns the rootpostinstallscript.Impact on contributors
None for the common setup (no global
core.hooksPath): hooks continue to auto-install into.git/hooks. Contributors who intentionally use a globalcore.hooksPathwill no longer have it overwritten; if they want this repo's hooks, they can opt in explicitly (e.g.bunx lefthook install --forceafter pointingcore.hooksPathat the repo).