[ez][trymerge] Edit revert message for reverted ghstack PRs (#153573)

Change comment about successful revert so it also contains info about the original PR that got the comment (if it is a ghstacked PR)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/153573
Approved by: https://github.com/atalman, https://github.com/malfet
This commit is contained in:
Catherine Lee
2025-05-15 18:23:20 +00:00
committed by PyTorch MergeBot
parent 480ae2dab8
commit 00e5cb3db3

View File

@ -1938,6 +1938,7 @@ def get_ghstack_dependent_prs(
def do_revert_prs(
repo: GitRepo,
original_pr: GitHubPR,
shas_and_prs: list[tuple[str, GitHubPR]],
*,
author_login: str,
@ -1959,9 +1960,16 @@ def do_revert_prs(
# Comment/reopen PRs
for commit_sha, pr in shas_and_prs:
revert_message = (
f"@{pr.get_pr_creator_login()} your PR has been successfully reverted."
)
revert_message = ""
if pr.pr_num == original_pr.pr_num:
revert_message += (
f"@{pr.get_pr_creator_login()} your PR has been successfully reverted."
)
else:
revert_message += (
f"@{pr.get_pr_creator_login()} your PR has been reverted as part of the stack under "
f"#{original_pr.pr_num}.\n"
)
if (
pr.has_internal_changes()
and not pr.has_no_connected_diff()
@ -2013,6 +2021,7 @@ def try_revert(
do_revert_prs(
repo,
pr,
shas_and_prs,
author_login=author_login,
extra_msg=extra_msg,