uros-b commented on code in PR #57764:
URL: https://github.com/apache/spark/pull/57764#discussion_r3714349345
##########
dev/merge_spark_pr.py:
##########
@@ -615,6 +705,72 @@ def _do_cherry_pick(pr_num, merge_hash, pick_ref):
return pick_ref, pick_hash
+def branches_with_merge_footer(pr_num, branch_names):
+ """Release branches from `branch_names` that already carry `pr_num`'s
merge footer.
+
+ A cherry-pick is a new commit, so `git branch --contains <merge_hash>`
finds only the
+ branch the change was merged into; what identifies a backport is the
footer, which
+ `cherry-pick -x` copies verbatim (the same signal `dev/pr_merge_status.py`
reads).
+ Best-effort: this only sees branches already fetched into
PUSH_REMOTE_NAME's tracking
+ refs, so a backport pushed from elsewhere and not yet fetched is simply
not reported --
+ the committer is still prompted and can type any branch.
+ """
+ trailer = "Closes #%s from " % pr_num
+ try:
+ out = run_cmd(
+ [
+ "git",
+ "log",
+ "--remotes=%s" % PUSH_REMOTE_NAME,
+ "--fixed-strings",
+ "--grep",
+ trailer,
Review Comment:
Correct, and this one was mine -- I introduced the same false-positive class
in the branch scan that `has_merge_footer` exists to prevent. `git log --grep`
is a substring match over the whole message, so a commit merely quoting `Closes
#N from ` made every branch containing it look already backported.
Fixed in 0853820: the scan now emits `%H %B` per record (NUL-delimited so
multi-line messages stay one field) and confirms each candidate with the
validated matcher before mapping it to branches. `--grep` is now only a cheap
pre-filter to narrow the walk.
Verified with a commit that quotes #57713's complete footer while its own
footer closes #58000:
```
branches reported for #57713 : [] (before: ['branch-4.2'])
for-each-ref calls made : 0 (rejected before branch
mapping)
branches reported for #58000 : ['branch-4.2'] (the real closer, still
found)
```
Real-repo results are unchanged by the added validation:
| PR | state | detected | default |
|---|---|---|---|
| #57745 | master, picked to `branch-4.x` | `branch-4.x` | `branch-4.3` |
| #57713 | `branch-4.x` only | `branch-4.x` | `branch-4.3` |
| #57696 | master only | none | `branch-4.x` |
--
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]