SIGN IN SIGN UP

Get collaborator role name (#3295)

This commits adds a duplicate of `get_collaborator_permission()`, which,
instead of returning `data["permission"]`, returns `data["role_name"]`.
The former only returns "admin", "write", "read", or "none"; the latter
now also tells us whether the collaborator has the "maintain" or
"triage" role.

I'm using PyGitHub to monitor ~1K repositories under my company's GitHub
organization, to ensure they stay in compliance with our policies, e.g.,
keeping track of the roles of outside collaborators, and making sure
they stay at "triage" or below. It's possible to achieve what we need to
using `get_collaborators()` with some combination of `affiliation` and
`permission`, but the addition of this new function means making
significantly fewer API calls and speeding up our monitoring CI jobs by
a factor of 2-3.

I realize this is a brute-force addition. If you're happy to accept it
as-is, great. If we need to clean things up such that there's less
duplication across the two functions, or clearer docstring to
differentiate the two, etc., just let me know.

---------

Co-authored-by: Enrico Minack <github@enrico.minack.dev>
J
Jason M. Gates committed
2d4785dd08374147a8eab866eeb704508558336a
Parent: 03e47ae
Committed by GitHub <noreply@github.com> on 7/21/2025, 6:50:46 PM