Yicong-Huang opened a new pull request, #58198:
URL: https://github.com/apache/spark/pull/58198

   ### What changes were proposed in this pull request?
   
   This adds a dry-run mode to `dev/merge_spark_pr.py` that performs every 
read-only step for real but suppresses every effect that leaves the local 
machine, logging a clear `DRY-RUN: would <action> ...` line instead of 
executing it. The suppressed effects are exactly the outbound ones:
   
   - the `git push` to `PUSH_REMOTE_NAME` (the only git command that reaches 
the shared apache repo; local fetch/checkout/squash-merge/cherry-pick still run 
on the throwaway `PR_TOOL_*` branches that `clean_up` removes, so conflicts and 
the computed merge hash stay realistic);
   - the GitHub PR close and the merge/summary comment (`close_pr`, 
`comment_pr`, `post_merge_comment`);
   - all JIRA writes: component updates, `fixVersions` updates, the resolve 
transition, assignee changes, and the contributor-role grant.
   
   Read-only steps still run so the flow is faithful: fetching the PR, the JIRA 
issue lookup and `project_versions`, and -- importantly -- JIRA and GitHub 
token validation (`initialize_jira()` and `get_json()` are not gated), so a dry 
run exercises the same credentials a real merge needs. Interactive prompts 
continue to work.
   
   Dry-run is enabled with a `--dry-run` / `-n` flag or the `DRY_RUN` 
environment variable, consistent with the script's existing env-based 
configuration. A small `parse_args` helper handles the flag (the script 
previously read `sys.argv` directly). Two new pure helpers (`parse_args` and 
`is_remote_mutating_git_cmd`) are covered by doctests.
   
   ### Why are the changes needed?
   
   Before this change there was no way to rehearse the full merge flow without 
producing real side effects. The existing affordances cover only part of it: 
doctests exercise the pure logic; `SKIP_VERSION_CHECK` lets a committer iterate 
against a real PR; and `PR_REMOTE_NAME` / `PUSH_REMOTE_NAME` can point the `git 
push` at a scratch fork. But `GITHUB_API_BASE` and `JIRA_API_BASE` are 
hardcoded to apache, so the PR close/comment and JIRA resolve paths cannot be 
redirected and always hit the real `apache/spark` repo and ASF JIRA. Dry-run is 
the first mechanism that makes the entire flow (git + GitHub + JIRA) 
side-effect-free while keeping it realistic, which is useful for previewing a 
merge and for iterating on the merge script itself.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No. This is a committer-facing dev tool; the new mode is opt-in and the 
default behavior is unchanged.
   
   ### How was this patch tested?
   
   - Doctests: `python -m doctest dev/merge_spark_pr.py` passes, including the 
new cases for `parse_args` and `is_remote_mutating_git_cmd` (92 tests total).
   - Manual smoke test with `DRY_RUN=1`: confirmed `run_cmd` suppresses `git 
push` (string and list forms) and returns `""` while a read-only `git 
rev-parse` still runs; `close_pr`, `comment_pr`, `post_merge_comment`, 
`grant_contributor_role`, and `assign_issue` all print their `DRY-RUN: would 
...` line and make no network call; and with dry-run off the default remains 
unchanged.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   No.
   


-- 
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