mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
Merge pull request #13543 from kfessel/backport_pr_check
tools/backport_pr: Add Token Scope check
This commit is contained in:
commit
385cd72ac6
14
dist/tools/backport_pr/backport_pr.py
vendored
14
dist/tools/backport_pr/backport_pr.py
vendored
@ -135,6 +135,20 @@ def main():
|
|||||||
if status != 200:
|
if status != 200:
|
||||||
print("Could not retrieve user: {}".format(user['message']))
|
print("Could not retrieve user: {}".format(user['message']))
|
||||||
exit(1)
|
exit(1)
|
||||||
|
# Token-scope-check: Is the token is powerful enough to complete
|
||||||
|
# the Backport?
|
||||||
|
response_headers = dict(g.getheaders())
|
||||||
|
# agithub documentation says it's lower case header field-names but
|
||||||
|
# at this moment it's not
|
||||||
|
if 'X-OAuth-Scopes' in response_headers:
|
||||||
|
scopes = response_headers['X-OAuth-Scopes']
|
||||||
|
else:
|
||||||
|
scopes = response_headers['x-oauth-scopes']
|
||||||
|
scopes_list = [x.strip() for x in scopes.split(',')]
|
||||||
|
if not ('public_repo' in scopes_list or 'repo' in scopes_list):
|
||||||
|
print("missing public_repo scope from token settings."
|
||||||
|
" Please add it on the GitHub webinterface")
|
||||||
|
exit(1)
|
||||||
username = user['login']
|
username = user['login']
|
||||||
status, pulldata = g.repos[ORG][REPO].pulls[args.PR].get()
|
status, pulldata = g.repos[ORG][REPO].pulls[args.PR].get()
|
||||||
if status != 200:
|
if status != 200:
|
||||||
|
Loading…
Reference in New Issue
Block a user