Skip to content

fix(#954): wire setup-git-hooks into root postinstall#984

Merged
joelteply merged 1 commit into
canaryfrom
fix/954-precommit-hook-postinstall
May 1, 2026
Merged

fix(#954): wire setup-git-hooks into root postinstall#984
joelteply merged 1 commit into
canaryfrom
fix/954-precommit-hook-postinstall

Conversation

@joelteply
Copy link
Copy Markdown
Contributor

Fresh contributors who clone + `npm install` at the repo root were silently bypassing the pre-commit gate. `src/package.json` already had a postinstall that runs `setup-git-hooks`, but it only fires when running `npm install` from `src/` — a fresh contributor running `npm install` at the root never triggered it.

Add a `postinstall` to root `package.json` that runs the same script.

Why this works

  • `setup-git-hooks.sh` is idempotent (early-exits when not in a git checkout, safely skips already-installed hooks).
  • Stderr/stdout NOT suppressed (unlike `src/`'s variant which bundles it with worker-models download). If hook setup fails, the user sees the warning + the manual command — per the never-swallow-errors rule.
  • Doesn't change `src/`'s postinstall — both can fire (it's the same script, idempotent).

Smoke-tested

```
$ bash src/scripts/setup-git-hooks.sh
📁 Installed: pre-commit pre-push
⏭️ Skipped (target script missing): post-commit
```

Closes #954.

Fresh contributors who clone + `npm install` at the repo root were
silently bypassing the pre-commit gate. src/package.json had a
postinstall that runs setup-git-hooks, but it only fires when running
`npm install` from `src/` — a fresh contributor running `npm install`
at the root never triggered it.

Add a postinstall to root package.json that runs the same script.
Idempotent (the script itself early-exits when not in a git checkout
and is safe to re-run when hooks already exist). Output visible
unlike src/'s suppressed variant — if hook setup fails the user sees
the warning + the manual command, per never-swallow-errors.

Smoke-tested locally: hook setup runs, installs pre-commit + pre-push,
skips post-commit (target script intentionally absent).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@joelteply joelteply merged commit 2ad536e into canary May 1, 2026
6 checks passed
@joelteply joelteply deleted the fix/954-precommit-hook-postinstall branch May 1, 2026 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant