Skip to content

fix: backport the landed commits of squash and rebase merges - #877

Merged
skjnldsv merged 1 commit into
masterfrom
fix/backport-squash-rebase-merges
Dec 1, 2026
Merged

skjnldsv merged 1 commit into
masterfrom
fix/backport-squash-rebase-merges

Conversation

@juliusknorr

Copy link
Copy Markdown
Member

/backport to <branch> cherry-picks the original commits of a pull request. After a squash or rebase merge those only exist on the head branch, so backports of fork PRs always failed, and same-repo PRs failed once their branch was deleted. The error said no cherry-pick or revert in progress, because the failed cherry-pick --abort replaced the real error. Example: Euro-Office/sdkjs#216, 26 of 49 backports failed this way.

  • Merged PRs: use the commits that landed on the base branch
    • merge commit: the original commits, as before
    • one commit: the merge commit SHA
    • rebase: the last N base commits whose subjects match (in any order)
    • squash: the merge commit when its subject ends with (#<pr>)
    • anything else: the original commits, with a warning
  • Fetch pull/<n>/head, so the original commits also exist for partial, forced and fallback requests
  • Report the cherry-pick error instead of the abort error

Tests: squash, rebase, unordered rebase, unknown method, merge commit, open PR, and the real cherry-pick error. 4 of them fail without the fix. The pull/<n>/head fetch has no unit test, because cloneAndCacheRepo hardcodes the github.com remote. Checked by hand against a fork PR, and live against Euro-Office PRs:

  • sdkjs#216 (fork, squash) → a9a939c9
  • sdkjs#236 (rebase) → both rebased commits
  • sdkjs#186 (5 commits, squash) → a08ac51c
  • core#148 (merge commit) → original commits

Full requests picked the original commits of a pull request. After a
squash or rebase merge those only live on the head branch, which is
often a fork or already deleted, so the cherry-pick failed. Use the
commits that landed on the base branch when the merge method is
certain, and fetch the pull request head so the original commits are
always available. Report the cherry-pick error instead of the failed
abort that hid it.

Signed-off-by: Julius Knorr <jus@bitgrid.net>
Assisted-by: ClaudeCode:claude-opus-5-5
@juliusknorr juliusknorr added the bug Something isn't working label Nov 30, 2026
@juliusknorr
juliusknorr marked this pull request as ready for review November 30, 2026 20:07
@juliusknorr
juliusknorr requested a review from skjnldsv November 30, 2026 20:07
@codecov

codecov Bot commented Nov 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.25000% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/githubUtils.ts 83.33% 2 Missing and 3 partials ⚠️
src/gitUtils.ts 50.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@skjnldsv skjnldsv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find !

@skjnldsv

skjnldsv commented Dec 1, 2026

Copy link
Copy Markdown
Member

26 of 49 backports failed this way.

ooof

@skjnldsv
skjnldsv merged commit 6dcee75 into master Dec 1, 2026
10 checks passed
@skjnldsv
skjnldsv deleted the fix/backport-squash-rebase-merges branch December 1, 2026 01:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants