Files
CherryHQ-cherry-studio/.pre-commit-config.yaml
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

41 lines
1.8 KiB
YAML

default_install_hook_types: [pre-commit, post-checkout, post-merge]
repos:
- repo: local
hooks:
- id: biome-format-js
name: Biome format (JS/TS)
language: system
entry: pnpm biome format --write --no-errors-on-unmatched
files: '\.(js|jsx|ts|tsx|cjs|mjs|cts|mts)$'
pass_filenames: true
- id: eslint-fix
name: ESLint fix
language: system
entry: pnpm eslint --fix
files: '\.(js|jsx|ts|tsx|cjs|mjs|cts|mts)$'
pass_filenames: true
- id: biome-format-other
name: Biome format (JSON/YAML/CSS/HTML)
language: system
entry: pnpm biome format --write --no-errors-on-unmatched
files: '\.(json|yml|yaml|css|html)$'
pass_filenames: true
- id: post-checkout-install
name: pnpm install after checkout
language: system
entry: bash -c 'if [ "$PRE_COMMIT_FROM_REF" != "$PRE_COMMIT_TO_REF" ] && git diff --name-only "$PRE_COMMIT_FROM_REF" "$PRE_COMMIT_TO_REF" -- "**/package.json" pnpm-lock.yaml | grep -q .; then echo "Dependencies changed, running pnpm install..."; pnpm install; else echo "No dependency changes, skipping pnpm install."; fi'
stages: [post-checkout]
always_run: true
pass_filenames: false
- id: post-merge-install
name: pnpm install after merge/pull
language: system
entry: bash -c 'PREV_HEAD=$(git rev-parse --short HEAD@{1} 2>/dev/null); if [ -n "$PREV_HEAD" ] && git diff --name-only "$PREV_HEAD" HEAD -- "**/package.json" pnpm-lock.yaml | grep -q .; then echo "Dependencies changed, running pnpm install..."; pnpm install; else echo "No dependency changes, skipping pnpm install."; fi'
stages: [post-merge]
always_run: true
pass_filenames: false