Skip to content

Commit 5d658b0

Browse files
committed
scripts: check_maintainer_changes: Fix GitHub user access check
The PyGithub `Repository.get_collaborator_permission` function invokes the GitHub REST API `/repos/{owner}/{repo}/collaborators/{username}/permission` and returns the value of the `permission` attribute in the response. As per the GitHub documentation [1], the `permission` attribute "provides the legacy base roles of admin, write, read and none, where the maintain role is mapped to write and the triage role is mapped to read", and this caused the users with `triage` permission level (i.e. the users in the `contributors` team) to be incorrectly flagged by the script. This commit updates the script to use the `get_collaborator_role_name` function, which correctly returns the up-to-date user permission/role name, including `maintain` and `triage`. Note that the `get_collaborator_role_name` function is only available in PyGithub>=2.7.0. [1] https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#get-repository-permissions-for-a-user Signed-off-by: Stephanos Ioannidis <[email protected]>
1 parent 85a2d69 commit 5d658b0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

scripts/ci/check_maintainer_changes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ def check_github_access(usernames, repo_fullname, token):
3030
missing_access = set()
3131
for username in usernames:
3232
try:
33-
collab = repo.get_collaborator_permission(username)
34-
# Permissions: admin, maintain, write, triage, read
33+
collab = repo.get_collaborator_role_name(username)
34+
# Roles: admin, maintain, write, triage, read
3535
if collab not in ("admin", "maintain", "write", "triage"):
3636
missing_access.add(username)
3737
except Exception:

0 commit comments

Comments
 (0)