[llvm] [GitHub] Add workflow to check author's commit access on new PRs (PR #123593)
Mats Jun Larsen via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 20 05:12:07 PST 2025
================
@@ -290,6 +290,32 @@ def run(self) -> bool:
return True
+class CheckCommitAccess:
+ def __init__(self, token: str, repo: str, pr_number: int, author: str):
+ self.repo = github.Github(token).get_repo(repo)
+ self.pr = self.repo.get_issue(pr_number).as_pull_request()
+ self.author = author
+
+ def can_merge(self, user: str) -> bool:
+ try:
+ return self.repo.get_collaborator_permission(user) in ["admin", "write"]
----------------
junlarsen wrote:
This is probably plenty sufficient, but there's also the collaborators endpoint that enumerates explicit permissions like push: https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#list-repository-collaborators
It does however require paginating through the list so this is probably kinder to the rate limits
https://github.com/llvm/llvm-project/pull/123593
More information about the llvm-commits
mailing list