From b4494cab21fa4661cf844e0266f577dcb2f2943e Mon Sep 17 00:00:00 2001 From: "Azalea (on HyDEV-Daisy)" Date: Tue, 30 Aug 2022 18:34:53 -0400 Subject: [PATCH] [O] Allow github token in accept_upstream.py --- tools/accept_upstream.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/accept_upstream.py b/tools/accept_upstream.py index e1b6e7ce..31490b82 100755 --- a/tools/accept_upstream.py +++ b/tools/accept_upstream.py @@ -12,6 +12,11 @@ upstream = 'dylanaraps/neofetch' my_fork = 'hykilpikonna/hyfetch' my_base = 'master' +http = requests.Session() +if 'GH_TOKEN' in os.environ: + print('Token loaded') + http.headers['Authorization'] = f'token {os.environ["GH_TOKEN"]}' + def copy_comment(): # Get commit SHA @@ -42,11 +47,11 @@ if __name__ == '__main__': print(f'Accepting pull request {pr}...') # Fetch original pr's information - info = requests.get(f'https://api.github.com/repos/{upstream}/pulls/{pr}').json() + info = http.get(f'https://api.github.com/repos/{upstream}/pulls/{pr}').json() user = info['user']['login'] # Fetch commit information - commits = requests.get(f'https://api.github.com/repos/{upstream}/pulls/{pr}/commits').json() + commits = http.get(f'https://api.github.com/repos/{upstream}/pulls/{pr}/commits').json() author = commits[0]['commit']['author'] # Create commit message