Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-45008][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? ### Was this patch authored or co-authored using generative AI tooling? Locally tested ```python >>> def get_json(url): ... try: ... request = Request(url) ... if GITHUB_OAUTH_KEY: ... request.add_header("Authorization", "token %s" % GITHUB_OAUTH_KEY) ... return json.load(urlopen(request)) ... except HTTPError as e: ... if "X-RateLimit-Remaining" in e.headers and e.headers["X-RateLimit-Remaining"] == "0": ... print( ... "Exceeded the GitHub API rate limit; see the instructions in " ... + "dev/merge_spark_pr.py to configure an OAuth token for making authenticated " ... + "GitHub requests." ... ) ... else: ... print("Unable to fetch URL, exiting: %s" % url) ... sys.exit(-1) ... >>> branches = get_json("%s/branches" % GITHUB_API_BASE) >>> >>> branch_names = list(filter(lambda x: x.startswith("branch-"), [x["name"] for x in branches])) >>> branch_names = sorted(branch_names, reverse=True) >>> branch_iter = iter(branch_names) >>> print(next(branch_iter, branch_names[0])) branch-3.5 >>> print(next(branch_iter, branch_names[0])) branch-3.4 >>> print(next(branch_iter, branch_names[0])) branch-3.3 >>> print(next(branch_iter, branch_names[0])) branch-3.2 >>> print(next(branch_iter, branch_names[0])) branch-3.1 >>> print(next(branch_iter, branch_names[0])) branch-3.0 >>> print(next(branch_iter, branch_names[0])) branch-2.4 >>> print(next(branch_iter, branch_names[0])) branch-2.3 >>> print(next(branch_iter, branch_names[0])) branch-2.2 >>> print(next(branch_iter, branch_names[0])) branch-2.1 >>> print(next(branch_iter, branch_names[0])) branch-2.0 >>> print(next(branch_iter, branch_names[0])) branch-1.6 >>> print(next(branch_iter, branch_names[0])) branch-1.5 >>> print(next(branch_iter, branch_names[0])) branch-1.4 >>> print(next(branch_iter, branch_names[0])) branch-1.3 >>> print(next(branch_iter, branch_names[0])) branch-1.2 >>> print(next(branch_iter, branch_names[0])) branch-1.1 >>> print(next(branch_iter, branch_names[0])) branch-1.0-jdbc >>> print(next(branch_iter, branch_names[0])) branch-1.0 >>> print(next(branch_iter, branch_names[0])) branch-0.9 >>> print(next(branch_iter, branch_names[0])) branch-0.8 >>> print(next(branch_iter, branch_names[0])) branch-0.7 >>> print(next(branch_iter, branch_names[0])) branch-0.6 >>> print(next(branch_iter, branch_names[0])) branch-0.5 >>> print(next(branch_iter, branch_names[0])) branch-3.5 >>> quit() ``` Closes apache#42723 from yaooqinn/SPARK-45008. Authored-by: Kent Yao <yao@apache.org> Signed-off-by: Dongjoon Hyun <dhyun@apple.com>
- Loading branch information