From dbe2ac2f688cb5299472601dd35cee58ff5e672c Mon Sep 17 00:00:00 2001 From: amilz <85324096+amilz@users.noreply.github.com> Date: Fri, 13 Mar 2026 11:02:09 -0700 Subject: [PATCH] fix(skill): improve cherry-pick-sync to handle squash-merged sync PRs Prior cherry-pick sync PRs are often squash-merged into the release branch, making git cherry unable to detect them as equivalent. The skill now finds the last sync PR on the release branch and uses it as the baseline instead of relying solely on git log range. --- .claude/skills/cherry-pick-sync/SKILL.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.claude/skills/cherry-pick-sync/SKILL.md b/.claude/skills/cherry-pick-sync/SKILL.md index 90da176e..5c901102 100644 --- a/.claude/skills/cherry-pick-sync/SKILL.md +++ b/.claude/skills/cherry-pick-sync/SKILL.md @@ -31,8 +31,26 @@ git branch -r --sort=-committerdate | grep 'origin/release/' | head -5 ### 2. Determine commits to cherry-pick +**Find the last sync point first.** Prior cherry-pick syncs are often squash-merged, so `git cherry` and `git log` cannot detect them as equivalent. Instead: + ```bash git fetch origin main + +# Find the most recent cherry-pick sync PR on the release branch +git log --oneline origin/ | grep -i -E "cherry.pick|sync.*main|bring back commits from main" | head -3 +``` + +Read the PR body of the most recent sync (use `gh pr view `) to identify which main commits it included. The **last main commit referenced** in that PR is your sync baseline. + +Then list only commits **after** the sync baseline: + +```bash +git log --oneline --reverse ..origin/main +``` + +If no prior sync PR exists, fall back to the full range: + +```bash git log --oneline --reverse origin/..origin/main ``` @@ -41,6 +59,7 @@ git log --oneline --reverse origin/..origin/main - User said to skip certain commits → exclude them. - Default → take ALL commits from the log above. - **Auto-skip** release-only commits: version bumps, CHANGELOG updates, "chore: release v*". Flag these as skipped with reason. +- **Auto-skip** commits already on release: use `git cherry -v origin/ origin/main` as a secondary check — lines starting with `-` are already applied. - Show the final commit list to the user and confirm before proceeding. ### 3. Check preconditions