holdenk commented on code in PR #60472:
URL: https://github.com/apache/spark/pull/60472#discussion_r4577185472
##########
dev/merge_spark_pr.py:
##########
@@ -1119,6 +1866,7 @@ def amend_commit_message(message):
"git",
"commit",
"--amend",
+ "--only",
Review Comment:
Pinned in 927971fa8c5: the `sampled()` mock asserts `--only` on every amend.
Dropping it fails three examples.
---
<sub>🤖 Posted by an AI agent (Claude Code · skill `none`) on behalf of
@holdenk.</sub>
<!-- agent-attribution v1: agent=claude-code; skill=none; operator=holdenk
-->
##########
dev/spark_merge_footer.py:
##########
@@ -108,8 +122,35 @@ def merge_footer_pr(message):
return int(matches[-1]) if matches else None
+def backport_pr(message):
+ """The backport PR merged by `message`, or None: a `Backport-PR` trailer
in the final
+ paragraph, after the generated footer, so one quoted in a body does not
count.
+
+ >>> footer = "Closes #7 from a/b.\\n\\nAuthored-by: A
<[email protected]>\\nSigned-off-by: C <[email protected]>"
+ >>> backport_pr("Fix\\n\\n%s\\nBackport-PR: #9\\nSigned-off-by: M
<[email protected]>" % footer)
+ 9
+ >>> backport_pr("Fix\\n\\nBackport-PR: #9\\n\\n" + footer) is None
+ True
+ >>> backport_pr("Fix\\n\\nBackport-PR: #9") is None
+ True
+
+ A trailing `skip-checks` paragraph, added for the post-merge CI sampling,
does not hide it:
+
+ >>> backport_pr("Fix\\n\\n%s\\nBackport-PR: #9\\n\\n\\nskip-checks:
true\\n" % footer)
+ 9
+ """
+ matches = list(_MERGE_FOOTER_RE.finditer(message))
+ if not matches:
+ return None
+ paragraphs = [p.strip() for p in message[matches[-1].start()
:].split("\n\n")]
+ while paragraphs and (not paragraphs[-1] or
paragraphs[-1].lower().startswith("skip-checks:")):
+ paragraphs.pop()
+ found = _BACKPORT_PR_RE.findall(paragraphs[-1]) if paragraphs else []
+ return int(found[-1]) if found else None
Review Comment:
Added in 927971fa8c5: a final paragraph with `Backport-PR: #9` then `#10`
reads as #10, counts as merging #10, and does not count as merging #9.
`found[0]` fails it.
---
<sub>🤖 Posted by an AI agent (Claude Code · skill `none`) on behalf of
@holdenk.</sub>
<!-- agent-attribution v1: agent=claude-code; skill=none; operator=holdenk
-->
##########
dev/merge_spark_pr.py:
##########
@@ -1263,21 +2621,49 @@ def _do_cherry_pick(pr_num, merge_hash, pick_ref):
else:
print("Cherry-pick already completed manually; continuing with the
backport.")
- raw_message = git.run(["git", "log", "-1", "--format=%B"])
- updated_message = remove_inherited_post_merge_ci_skip(raw_message)
- if skip_post_merge_ci:
- updated_message = append_post_merge_ci_skip(updated_message)
- if updated_message != raw_message:
- amend_commit_message(updated_message)
+ _set_skip_trailer(False)
- continue_maybe(
- "Pick complete (local ref %s). Push to %s?" % (pick_branch_name,
PUSH_REMOTE_NAME)
- )
+ maybe_binding_policy_warning(pick_ref, pick_head)
+ maybe_compile_check(pick_branch_name)
- try:
- git.push(PUSH_REMOTE_NAME, pick_branch_name, pick_ref)
- except Exception as e:
- fail("Exception while pushing: %s" % e)
+ while True:
+ choice = _landing_choice(pick_branch_name, pick_ref)
+ if choice == "s":
+ # Restore the original checkout and drop the temp PICK_PR_*
branches, as the
+ # continue_maybe decline path does; otherwise a later pick of the
same ref fails
+ # when `git fetch` tries to update the checked-out branch.
+ print("Skipping this branch; the merge continues.")
+ _restore_original_head()
+ clean_up()
+ raise SkipCherryPick()
+ if choice == "p":
+ _set_skip_trailer(False)
+ marker = _land_via_fork(pr_num, pick_ref, pick_branch_name, title)
+ if marker:
+ clean_up()
+ return pick_ref, marker
+ # Nothing was pushed and the pick is intact: retry, push directly,
or skip.
+ continue
+ if pending_sibling:
+ sibling, marker = pending_sibling
+ prompt = (
+ "Upstream-First: %s has only a pending backport (%s). Push %s
directly as a "
+ "%s-only maintenance fix?" % (sibling, marker, pick_ref,
pick_ref)
+ )
+ if get_input(f"{prompt} (y/N): ", ["y", "n", ""]) != "y":
Review Comment:
Added in 927971fa8c5, one case for each path. With branch-4.x pending: an
accepted confirmation pushes once, `[p]` lands without asking, and a skip in
the pending path returns `[]` without ending the run. `[b]oth` with branch-4.x
on a backport PR and branch-4.2 skipped returns the branch-4.x pick with its
URL.
---
<sub>🤖 Posted by an AI agent (Claude Code · skill `none`) on behalf of
@holdenk.</sub>
<!-- agent-attribution v1: agent=claude-code; skill=none; operator=holdenk
-->
##########
dev/merge_spark_pr.py:
##########
@@ -1263,21 +2621,49 @@ def _do_cherry_pick(pr_num, merge_hash, pick_ref):
else:
print("Cherry-pick already completed manually; continuing with the
backport.")
- raw_message = git.run(["git", "log", "-1", "--format=%B"])
- updated_message = remove_inherited_post_merge_ci_skip(raw_message)
- if skip_post_merge_ci:
- updated_message = append_post_merge_ci_skip(updated_message)
- if updated_message != raw_message:
- amend_commit_message(updated_message)
+ _set_skip_trailer(False)
- continue_maybe(
- "Pick complete (local ref %s). Push to %s?" % (pick_branch_name,
PUSH_REMOTE_NAME)
- )
+ maybe_binding_policy_warning(pick_ref, pick_head)
+ maybe_compile_check(pick_branch_name)
- try:
- git.push(PUSH_REMOTE_NAME, pick_branch_name, pick_ref)
- except Exception as e:
- fail("Exception while pushing: %s" % e)
+ while True:
+ choice = _landing_choice(pick_branch_name, pick_ref)
+ if choice == "s":
+ # Restore the original checkout and drop the temp PICK_PR_*
branches, as the
+ # continue_maybe decline path does; otherwise a later pick of the
same ref fails
+ # when `git fetch` tries to update the checked-out branch.
+ print("Skipping this branch; the merge continues.")
+ _restore_original_head()
Review Comment:
Added in 927971fa8c5: with `original_head` set, `[s]` must run `git checkout
--quiet master` and `clean_up()` once, and a successful `[p]` must call
`clean_up()` once. Removing either call fails it.
---
<sub>🤖 Posted by an AI agent (Claude Code · skill `none`) on behalf of
@holdenk.</sub>
<!-- agent-attribution v1: agent=claude-code; skill=none; operator=holdenk
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]