[mergebot] Fix mergebot allow revert of codev diff (#91975)

mergebot was allowing non facebook-github-bot users to revert codev diffs when it shouldnt be allowed

Fixes https://github.com/pytorch/test-infra/issues/1381
Pull Request resolved: https://github.com/pytorch/pytorch/pull/91975
Approved by: https://github.com/ZainRizvi, https://github.com/kit1980, https://github.com/malfet
This commit is contained in:
Catherine Lee
2023-01-11 01:59:05 +00:00
committed by PyTorch MergeBot
parent 6b542147a3
commit de4e4c785a
3 changed files with 1965 additions and 2 deletions

View File

@ -1263,8 +1263,11 @@ def validate_revert(repo: GitRepo, pr: GitHubPR, *,
commit_sha = commits[0]
msg = repo.commit_message(commit_sha)
rc = RE_DIFF_REV.search(msg)
if rc is not None and not can_skip_internal_checks:
raise PostCommentError(f"Can't revert PR that was landed via phabricator as {rc.group(1)}")
if rc is not None and not skip_internal_checks:
raise PostCommentError(
f"Can't revert PR that was landed via phabricator as {rc.group(1)}. " +
"Please revert by going to the internal diff and clicking Unland."
)
return (author_login, commit_sha)