Skip to content

Commit

Permalink
[GHF] Bot should reopen PR after revert (pytorch#112614)
Browse files Browse the repository at this point in the history
  • Loading branch information
malfet authored and xuhancn committed Nov 8, 2023
1 parent 09fe5d0 commit c8619f9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/scripts/github_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,8 @@ def gh_fetch_merge_base(org: str, repo: str, base: str, head: str) -> str:
warnings.warn(f"Failed to get merge base for {base}...{head}: {error}")

return merge_base


def gh_update_pr_state(org: str, repo: str, pr_num: int, state: str = "open") -> None:
url = f"{GITHUB_API_URL}/repos/{org}/{repo}/pulls/{pr_num}"
gh_fetch_url(url, method="PATCH", data={"state": state})
2 changes: 2 additions & 0 deletions .github/scripts/trymerge.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
gh_fetch_url,
gh_post_commit_comment,
gh_post_pr_comment,
gh_update_pr_state,
GitHubComment,
)

Expand Down Expand Up @@ -1803,6 +1804,7 @@ def post_comment(msg: str) -> None:
if not dry_run:
pr.add_numbered_label("reverted")
gh_post_commit_comment(pr.org, pr.project, commit_sha, revert_msg)
gh_update_pr_state(pr.org, pr.project, pr.pr_num)


def prefix_with_github_url(suffix_str: str) -> str:
Expand Down

0 comments on commit c8619f9

Please sign in to comment.