holdenk commented on code in PR #60471:
URL: https://github.com/apache/spark/pull/60471#discussion_r4576443943


##########
dev/merge_spark_pr.py:
##########
@@ -1010,19 +1039,65 @@ class SkipCherryPick(Exception):
     """
 
 
-def continue_maybe(prompt, cherry=False):
+def continue_maybe(prompt: str, cherry: bool = False) -> None:
+    """Prompt to continue; on "no" either skip this cherry-pick (`cherry`) or 
exit the script.
+
+    `cherry` is the decline semantics, not a statement that a cherry-pick is 
mid-flight: the
+    pre-push checks run after the pick is committed, and declining there must 
still skip only
+    that branch. So the abort is attempted only when git says one is actually 
in progress.
+
+    >>> from contextlib import redirect_stdout
+    >>> from io import StringIO
+    >>> from unittest.mock import call, patch
+
+    Declining with `cherry` while a pick is mid-flight aborts the pick before 
skipping --

Review Comment:
   Fixed in 466772a7576: added a no-pick decline that asserts there is no abort 
and that the checkout is retried, plus probe cases for success, exit 1, exit 
128 and `OSError`. Forcing the abort, or making the probe always answer False, 
now fails a doctest.
   
   ---
   <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:
##########
@@ -1035,6 +1110,353 @@ def clean_up():
             git.run("git branch -D %s" % branch)
 
 
+def maybe_compile_check(ref_name: str) -> None:
+    """Offer to run a clean SBT compile of main and test sources before 
pushing `ref_name`.
+
+    `ref_name` is the checked-out cherry-pick, so a clean compile here catches 
a mis-resolved
+    conflict, or a PR that bit-rotted against the target branch, before it 
lands. It is a smoke
+    test (see COMPILE_CHECK_CMD), not CI: modules behind other profiles are 
not compiled.
+    Declining skips the check. A red build asks rather than aborts, because a 
non-zero sbt is
+    as easily a JDK the branch rejects or a failed download as it is the 
backport; declining
+    there skips this branch (see continue_maybe). Output streams so a long 
compile does not
+    look like a hang.
+
+    What is compiled is the working tree, not the commit: a file re-edited 
after the merge
+    commit, or an untracked source file left over from a manual conflict 
resolution, compiles
+    here and is absent from the push. (A resolved-but-never-`git add`ed 
conflict is NOT the
+    case -- the commit itself fails while files are unmerged, so the check is 
never reached.)
+    So warn when the tree is dirty rather than report a green that is about 
something else,
+    and name the remedy (`git add` + `git commit --amend`) since the fix is 
the commit, not
+    the build.
+
+    Declining runs no build and no git -- the git.run mock raises if a 
regression moves a
+    git call above the prompt, which otherwise would run real git in the 
committer's repo on
+    every startup (doctest.testmod() runs on invocation):
+
+    >>> from contextlib import redirect_stdout
+    >>> from io import StringIO
+    >>> from unittest.mock import call, patch
+    >>> with (
+    ...     patch("builtins.input", return_value=""),
+    ...     patch.object(git, "run", side_effect=AssertionError("should not 
run git")),
+    ...     patch("subprocess.call") as run,
+    ...     redirect_stdout(StringIO()),
+    ... ):
+    ...     maybe_compile_check("PR_TOOL_PICK_PR_1_BRANCH-4.1")
+    >>> run.call_count
+    0
+
+    Accepting runs the SBT compile once, from the repo root, with an explicit 
-P so SparkBuild
+    does not fall back to `-Psbt`; a green build returns quietly. The two git 
calls are pinned
+    too -- transposing them or dropping --porcelain would otherwise stay green:
+
+    >>> with (
+    ...     patch("builtins.input", return_value="y"),

Review Comment:
   Fixed in 466772a7576: the green-build examples get exactly one answer, and 
the interrupted/unrunnable loop asserts both prompts were used. Dropping the 
`return` after a pass, or returning right after an interrupt, now fails a 
doctest.
   
   ---
   <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]

Reply via email to