From 28449630f3fc60318f095773b2e2be68144c00da Mon Sep 17 00:00:00 2001 From: Kent Yao Date: Fri, 1 Sep 2023 00:20:42 +0800 Subject: [PATCH] [CELEBORN-937][INFRA] Improve branch suggestion for backporting ### What changes were proposed in this pull request? This PR automatically iterates to the next branch to be merged instead of using the latest all the time ### Why are the changes needed? anti-misoperation ### Does this PR introduce _any_ user-facing change? no ### How was this patch tested? manully Closes #1870 from yaooqinn/CELEBORN-937. Authored-by: Kent Yao Signed-off-by: zky.zhoukeyong --- dev/merge_pr.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/dev/merge_pr.py b/dev/merge_pr.py index 35c4602a9bb..f46370d5952 100755 --- a/dev/merge_pr.py +++ b/dev/merge_pr.py @@ -528,7 +528,8 @@ def main(): branches = get_json("%s/branches" % GITHUB_API_BASE) branch_names = list(filter(lambda x: x.startswith("branch-"), [x["name"] for x in branches])) # Assumes branch names can be sorted lexicographically - latest_branch = sorted(branch_names, reverse=True)[0] + branch_names = sorted(branch_names, reverse=True) + branch_iter = iter(branch_names) pr_num = input("Which pull request would you like to merge? (e.g. 34): ") pr = get_json("%s/pulls/%s" % (GITHUB_API_BASE, pr_num)) @@ -600,7 +601,7 @@ def main(): fail("Couldn't find any merge commit for #%s, you may need to update HEAD." % pr_num) print("Found commit %s:\n%s" % (merge_hash, message)) - cherry_pick(pr_num, merge_hash, latest_branch) + cherry_pick(pr_num, merge_hash, next(branch_iter, branch_names[0])) sys.exit(0) if not bool(pr["mergeable"]): @@ -620,7 +621,9 @@ def main(): pick_prompt = "Would you like to pick %s into another branch?" % merge_hash while input("\n%s (y/n): " % pick_prompt).lower() == "y": - merged_refs = merged_refs + [cherry_pick(pr_num, merge_hash, latest_branch)] + merged_refs = merged_refs + [ + cherry_pick(pr_num, merge_hash, next(branch_iter, branch_names[0])) + ] if asf_jira is not None: continue_maybe("Would you like to update an associated JIRA?")