Skip to content

Commit 352acfa

Browse files
authored
Translate role names to handle GitHub API inconsistency (#8)
See github/rest-api-description#1378 Closes #7
1 parent 455c76f commit 352acfa

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

sync-teams-to-gh.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,13 @@ def http_method(url, data={}, method=None, fail_ok=False):
260260

261261
gh_role = response.get("role_name")
262262

263+
# The GitHub API has inconsistent role values, so we need to translate.
264+
# https://github.com/github/rest-api-description/issues/1378
265+
gh_role = {
266+
"write": "push",
267+
"read": "pull"
268+
}.get(gh_role, gh_role)
269+
263270
if gh_role != role:
264271
if role is None:
265272
qprint(f"🔧 Revoking `{team_slug}` access from repo `{owner}/{repo}`")

0 commit comments

Comments
 (0)