Skip to content

Commit

Permalink
[CELEBORN-937][INFRA] Improve branch suggestion for backporting
Browse files Browse the repository at this point in the history
### 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 apache#1870 from yaooqinn/CELEBORN-937.

Authored-by: Kent Yao <[email protected]>
Signed-off-by: zky.zhoukeyong <[email protected]>
  • Loading branch information
yaooqinn authored and waitinfuture committed Aug 31, 2023
1 parent 7da6942 commit 2844963
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions dev/merge_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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"]):
Expand All @@ -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?")
Expand Down

0 comments on commit 2844963

Please sign in to comment.