Skip to content

[SPARK-57077][INFRA] Prevent merging draft PRs in merge script#56120

Closed
zhengruifeng wants to merge 2 commits into
apache:masterfrom
zhengruifeng:merge-script-block-draft-pr-dev3
Closed

[SPARK-57077][INFRA] Prevent merging draft PRs in merge script#56120
zhengruifeng wants to merge 2 commits into
apache:masterfrom
zhengruifeng:merge-script-block-draft-pr-dev3

Conversation

@zhengruifeng
Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Add a fail-hard check in dev/merge_spark_pr.py that aborts when the target PR is a draft (pr["draft"] == True). The check sits next to the existing [WIP]/[DO-NOT-MERGE] title guard.

Why are the changes needed?

A draft PR is, by definition, not ready for merge. The script today only inspects the title for [WIP]/[DO-NOT-MERGE], so a committer who runs it against a draft PR whose title looks final can still kick off the merge flow. Checking the GitHub API's draft flag closes that gap.

Does this PR introduce any user-facing change?

No. Committer tooling only.

How was this patch tested?

Existing doctests in dev/merge_spark_pr.py still pass (python3 -m doctest dev/merge_spark_pr.py — 57/57).

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Opus 4.7)

Generated-by: Claude Code (Opus 4.7)
@zhengruifeng zhengruifeng changed the title [MINOR][INFRA] Prevent merging draft PRs in merge script [SPARK-57077][INFRA] Prevent merging draft PRs in merge script May 26, 2026
@zhengruifeng
Copy link
Copy Markdown
Contributor Author

use the updated script to merge this draft PR gets:

(spark-dev-313) ➜  spark git:(merge-script-block-draft-pr-dev3) dev/merge_spark_pr.py
git rev-parse --abbrev-ref HEAD
Which pull request would you like to merge? (e.g. 34): 56120
Cannot merge a draft PR #56120: [SPARK-57077][INFRA] Prevent merging draft PRs in merge script
Restoring head pointer to merge-script-block-draft-pr-dev3
git checkout merge-script-block-draft-pr-dev3
Already on 'merge-script-block-draft-pr-dev3'
git branch
Restoring head pointer to merge-script-block-draft-pr-dev3
git checkout merge-script-block-draft-pr-dev3
Already on 'merge-script-block-draft-pr-dev3'
git branch

@zhengruifeng zhengruifeng marked this pull request as ready for review May 26, 2026 10:53
Comment thread dev/merge_spark_pr.py

# Fail hard on draft PRs to prevent accidental merges.
if pr.get("draft", False):
fail("Cannot merge a draft PR #%s: %s" % (pr_num, title))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is simple, could you merge this into the above existing logic like the following? I guess this new message is more proper to cover all WIP cases.

if pr.get("draft", False) or "[WIP]" in title or "[DO-NOT-MERGE]" in title:
    fail("Cannot merge a draft PR #%s: %s" % (pr_num, title))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good

Generated-by: Claude Code (Opus 4.7)
@zhengruifeng
Copy link
Copy Markdown
Contributor Author

thanks, merged to master

@zhengruifeng zhengruifeng deleted the merge-script-block-draft-pr-dev3 branch May 27, 2026 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants