Skip to content

Commit 124cd11

Browse files
committed
Revert "[GitHub][workflows] Ask reviewers to merge PRs when author cannot (#81142)"
This reverts commit 38c706e. This workflow always fails in cases where it needs to create a comment, due to a permissions issue, see the discussion at: https://discourse.llvm.org/t/rfc-fyi-pull-request-greetings-for-new-contributors/75458/20
1 parent 55a7ff8 commit 124cd11

File tree

2 files changed

+0
-104
lines changed

2 files changed

+0
-104
lines changed

.github/workflows/approved-prs.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

llvm/utils/git/github-automation.py

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -298,55 +298,6 @@ def run(self) -> bool:
298298
return True
299299

300300

301-
class PRMergeOnBehalfInformation:
302-
COMMENT_TAG = "<!--LLVM MERGE ON BEHALF INFORMATION COMMENT-->\n"
303-
304-
def __init__(
305-
self, token: str, repo: str, pr_number: int, author: str, reviewer: str
306-
):
307-
self.repo = github.Github(token).get_repo(repo)
308-
self.pr = self.repo.get_issue(pr_number).as_pull_request()
309-
self.author = author
310-
self.reviewer = reviewer
311-
312-
def can_merge(self, user: str) -> bool:
313-
try:
314-
return self.repo.get_collaborator_permission(user) in ["admin", "write"]
315-
# There is a UnknownObjectException for this scenario, but this method
316-
# does not use it.
317-
except github.GithubException as e:
318-
# 404 means the author was not found in the collaborator list, so we
319-
# know they don't have push permissions. Anything else is a real API
320-
# issue, raise it so it is visible.
321-
if e.status != 404:
322-
raise e
323-
return False
324-
325-
def run(self) -> bool:
326-
# Check this first because it only costs 1 API point.
327-
if self.can_merge(self.author):
328-
return
329-
330-
# A review can be approved more than once, only comment the first time.
331-
for comment in self.pr.as_issue().get_comments():
332-
if self.COMMENT_TAG in comment.body:
333-
return
334-
335-
# This text is using Markdown formatting.
336-
if self.can_merge(self.reviewer):
337-
comment = f"""\
338-
{self.COMMENT_TAG}
339-
@{self.reviewer} the PR author does not have permission to merge their own PRs yet. Please merge on their behalf."""
340-
else:
341-
comment = f"""\
342-
{self.COMMENT_TAG}
343-
@{self.reviewer} the author of this PR does not have permission to merge and neither do you.
344-
Please find someone who has merge permissions who can merge it on the author's behalf. This could be one of the other reviewers or you can ask on [Discord](https://discord.com/invite/xS7Z362)."""
345-
346-
self.pr.as_issue().create_comment(comment)
347-
return True
348-
349-
350301
def setup_llvmbot_git(git_dir="."):
351302
"""
352303
Configure the git repo in `git_dir` with the llvmbot account so
@@ -714,17 +665,6 @@ def execute_command(self) -> bool:
714665
pr_buildbot_information_parser.add_argument("--issue-number", type=int, required=True)
715666
pr_buildbot_information_parser.add_argument("--author", type=str, required=True)
716667

717-
pr_merge_on_behalf_information_parser = subparsers.add_parser(
718-
"pr-merge-on-behalf-information"
719-
)
720-
pr_merge_on_behalf_information_parser.add_argument(
721-
"--issue-number", type=int, required=True
722-
)
723-
pr_merge_on_behalf_information_parser.add_argument("--author", type=str, required=True)
724-
pr_merge_on_behalf_information_parser.add_argument(
725-
"--reviewer", type=str, required=True
726-
)
727-
728668
release_workflow_parser = subparsers.add_parser("release-workflow")
729669
release_workflow_parser.add_argument(
730670
"--llvm-project-dir",
@@ -784,11 +724,6 @@ def execute_command(self) -> bool:
784724
args.token, args.repo, args.issue_number, args.author
785725
)
786726
pr_buildbot_information.run()
787-
elif args.command == "pr-merge-on-behalf-information":
788-
pr_merge_on_behalf_information = PRMergeOnBehalfInformation(
789-
args.token, args.repo, args.issue_number, args.author, args.reviewer
790-
)
791-
pr_merge_on_behalf_information.run()
792727
elif args.command == "release-workflow":
793728
release_workflow = ReleaseWorkflow(
794729
args.token,

0 commit comments

Comments
 (0)