This is an automated email from the ASF dual-hosted git repository.
szehon-ho pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new 681afc2b500c [SPARK-57203][INFRA] Improve dev/merge_spark_pr.py to
continue prompting on mistyped branch name
681afc2b500c is described below
commit 681afc2b500ccce1782d9f29c75c7fbb8c5a3ed8
Author: Szehon Ho <[email protected]>
AuthorDate: Tue Jun 2 11:16:26 2026 -0700
[SPARK-57203][INFRA] Improve dev/merge_spark_pr.py to continue prompting on
mistyped branch name
### What changes were proposed in this pull request?
This PR makes the cherry-pick branch prompt in `dev/merge_spark_pr.py`
re-prompt on a typo instead of crashing.
Previously, `cherry_pick` read a branch name and passed it straight to
`_do_cherry_pick`, whose first action is `git fetch <PUSH_REMOTE>
<pick_ref>:<temp>`. `run_cmd` uses `subprocess.check_output`, which raises
`CalledProcessError` on a non-zero exit. The `try/except` in `_do_cherry_pick`
only wraps the later `git cherry-pick` call, not this fetch, so a mistyped
branch name made the fetch fail and the exception propagated to the top-level
handler in `main`, which cleaned up the temp [...]
The branch prompt now validates the entered name against `branch_names`
(the list of `branch-*` release branches already fetched from the GitHub API)
in a loop. On an unrecognized name it prints the list of valid branches and
re-prompts; an empty input still accepts the default branch (which is always
valid).
### Why are the changes needed?
Mistyping a branch name at the cherry-pick prompt is an easy mistake for a
committer to make, and it previously crashed the whole merge tool, forcing the
committer to restart the merge/backport flow. Re-prompting lets them simply
correct the typo and continue.
### Does this PR introduce _any_ user-facing change?
No. This only affects the committer-facing behavior of the merge tool: the
cherry-pick branch prompt now re-prompts on an invalid branch name instead of
aborting.
### How was this patch tested?
Ran the module's doctests (`python3 -m doctest dev/merge_spark_pr.py`); all
57 tests pass. Manually verified the validation loop re-prompts on an unknown
branch and accepts both a valid branch and the default (empty input).
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Cursor (Claude Opus 4.8)
Closes #56261 from szehon-ho/strengthen_merge_spark_pr.
Authored-by: Szehon Ho <[email protected]>
Signed-off-by: Szehon Ho <[email protected]>
---
dev/merge_spark_pr.py | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/dev/merge_spark_pr.py b/dev/merge_spark_pr.py
index f484ad819501..c82b930e56ec 100755
--- a/dev/merge_spark_pr.py
+++ b/dev/merge_spark_pr.py
@@ -543,9 +543,17 @@ def cherry_pick(pr_num, merge_hash, default_branch,
branch_names, target_ref, al
maintenance-only bugfix). Returns the list of refs actually picked into, so
the main loop can advance its remaining-branches list correctly.
"""
- pick_ref = bold_input("Enter a branch name [%s]: " % default_branch)
- if pick_ref == "":
- pick_ref = default_branch
+ while True:
+ pick_ref = bold_input(f"Enter a branch name [{default_branch}]: ")
+ if pick_ref == "":
+ pick_ref = default_branch
+ if pick_ref in branch_names:
+ break
+ valid_branches = ", ".join(branch_names)
+ print_error(
+ f"'{pick_ref}' is not a known release branch. "
+ f"Valid branches: {valid_branches}. Please try again."
+ )
sibling_x = _upstream_first_sibling(target_ref, pick_ref, branch_names,
already_picked)
if sibling_x is not None:
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]