Skip to content

[INFRA] Improve pull request merge tool - #7654

Open
pan3793 wants to merge 8 commits into
apache:masterfrom
pan3793:merge-pr-script
Open

[INFRA] Improve pull request merge tool#7654
pan3793 wants to merge 8 commits into
apache:masterfrom
pan3793:merge-pr-script

Conversation

@pan3793

@pan3793 pan3793 commented Aug 24, 2026

Copy link
Copy Markdown
Member

Why are the changes needed?

This ports several useful improvements from Spark's merge tool, adapted to Kyuubi's GitHub-only workflow. It makes merges and backports safer, more traceable, and less error-prone for committers.

  • Suggest backport branches in descending release order, such as branch-1.12, then branch-1.11, and skip branches already picked.
  • Post a merge summary comment listing every branch and full commit link where the change landed.
  • Normalize confirmation prompts to (y/N).
  • Detect already-merged PRs more robustly, including reopened PRs and merges referenced by commits.
  • Explicitly close PRs merged into non-default branches when GitHub does not auto-close them.
  • Validate PR numbers, yes/no answers, and backport branch names before proceeding.
  • Derive lead and co-authors from GitHub-linked commits, defaulting the lead author to the PR author.
  • Apply Black formatting to the merge script.

How was this patch tested?

  • python3 -m py_compile dev/merge_kyuubi_pr.py
  • python3 -m doctest dev/merge_kyuubi_pr.py
  • black --check dev/merge_kyuubi_pr.py
  • git diff --check

Was this patch assisted by generative AI tooling?

Assisted-by: Codex:GLM 5.3

@wangzhigang1999

Copy link
Copy Markdown
Contributor

The referenced-event fallback does not recognize merge messages generated by this script

_MERGE_FOOTER_RE requires Authored-by or Lead-authored-by to appear immediately after the Closes #<pr> from ... paragraph. However, merge_pr inserts the linked issue and original commit summaries between those paragraphs.

This does not affect the first merge of a new PR or backports completed in the same script run. It affects a later invocation that uses an already-merged PR number to continue backporting.

I reproduced this with the existing release-branch PR [#7116](#7116), which was merged into branch-1.10 as commit [7c6d5658](7c6d565). Its relevant events are:

referenced  7c6d5658298447ba440cd424d232b4d062573a69
closed      commit_id=None

The merge message contains:

Closes #7116 from turboFei/fix_conflicts.

Closes #7101

f25f487e8 [Wang, Fei] [KYUUBI #7101][1.10][FOLLOWUP] Fix code broken

Authored-by: Wang, Fei <fwang12@ebay.com>

Running the code from this PR against those events gives:

find_merge_commit(7116, events)
# (None, None)

Since the closed event has no commit ID, find_merge_commit must use the referenced commit. The regex rejects its message, so a later invocation fails to recognize that PR #7116 has already landed and continues through the normal merge path instead of the backport path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants