From 92ef2c0edf1395da0a7b89e79aa256b374bd8b93 Mon Sep 17 00:00:00 2001 From: Phantom Date: Fri, 27 Feb 2026 11:25:09 +0800 Subject: [PATCH] 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 ``` --- .pre-commit-config.yaml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 81fd9e9d92..c56f82f24a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,4 @@ -default_install_hook_types: [pre-commit, post-checkout] +default_install_hook_types: [pre-commit, post-checkout, post-merge] repos: - repo: local @@ -30,4 +30,12 @@ repos: 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 \ No newline at end of file