Commit Graph

3 Commits

Author SHA1 Message Date
Phantom
92ef2c0edf chore: Add post-merge hook for automatic pnpm install (#13089)
### What this PR does

Adds automatic `pnpm install` execution after `git pull` or `git merge`
by configuring a post-merge hook via pre-commit.

### Why we need it and why it was done in this way

Developers often forget to run `pnpm install` after pulling changes,
leading to inconsistent dependency states. This hook automatically
detects changes to `package.json` or `pnpm-lock.yaml` and runs the
install command.

The following tradeoffs were made:

- Following the existing post-checkout pattern (not using
--frozen-lockfile)

The following alternatives were considered: None

### Breaking changes

None.

### Special notes for your reviewer

Run `pnpm prepare` after merging to activate the hook.

### Checklist

- [x] PR: The PR description is expressive enough and will help future
contributors
- [x] Code: Write code that humans can understand and keep it simple
- [x] Refactor: You have left the code cleaner than you found it
- [x] Upgrade: Impact of this change on upgrade flows was considered
- [ ] Documentation: Not required (dev tooling change)
- [x] Self-review: I have reviewed my own code

### Release note

```release-note
NONE
```
2026-02-27 11:25:09 +08:00
SuYao
d8e28616a1 feat(maintenance): add post-checkout hook to auto-run pnpm install on dependency changes (#13033)
### What this PR does

Before this PR:
After switching branches with `git checkout`, dependencies are not
automatically synced, potentially causing stale `node_modules`.

After this PR:
A prek `post-checkout` hook automatically runs `pnpm install` when
`package.json` or `pnpm-lock.yaml` changes between branches. If no
dependency files changed, the install is skipped.

Fixes # N/A

### Why we need it and why it was done in this way

The following tradeoffs were made:
Uses an inline bash script in the prek hook entry to keep configuration
self-contained without requiring an external script file.

The following alternatives were considered:
A raw `.git/hooks/post-checkout` script was considered, but using prek
keeps all hooks managed in one place via `.pre-commit-config.yaml`.

Links to places where the discussion took place: N/A

### Breaking changes

None.

### Special notes for your reviewer

- The hook uses `PRE_COMMIT_FROM_REF` and `PRE_COMMIT_TO_REF`
environment variables provided by prek during `post-checkout` stage.
- Requires `prek install -t post-checkout` to register the hook after
pulling this change.

### Checklist

- [x] PR: The PR description is expressive enough and will help future
contributors
- [x] Code: Write code that humans can understand and Keep it simple
- [x] Refactor: You have left the code cleaner than you found it (Boy
Scout Rule)
- [ ] Upgrade: Impact of this change on upgrade flows was considered and
addressed if required
- [ ] Documentation: N/A

### Release note

```release-note
NONE
```

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 14:38:49 +08:00
SuYao
1885f9cecb feat: migrate from husky to prek for git hooks (#12491)
* feat: migrate from husky to prek for git hooks

Replace husky + lint-staged with prek (pre-commit re-engineered in Rust) for
faster and more efficient git hooks management.

Changes:
- Add @j178/prek dependency
- Create .pre-commit-config.yaml with equivalent hooks
- Update prepare script to use prek install
- Remove husky, lint-staged dependencies and configuration
- Remove .husky directory

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* build: add @j178/prek to onlyBuiltDependencies

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: icarus <eurfelux@gmail.com>
2026-01-17 14:22:58 +08:00