From 667293445bcb8ff2e42930bfb8658f8ce782a35b Mon Sep 17 00:00:00 2001 From: Kane Ho Date: Wed, 21 Sep 2022 23:44:03 -0700 Subject: [PATCH] [Chore] Provide token when getting 401 error Issue #87 In GHE, token is necessary when querying the repo API, When it fails, it returns 401 error. Will need to specify the token in this case. --- pull-request.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pull-request.py b/pull-request.py index 5b926d5..6a72005 100755 --- a/pull-request.py +++ b/pull-request.py @@ -239,7 +239,7 @@ def find_default_branch(): response = requests.get(REPO_URL) # Case 1: 404 might need a token - if response.status_code == 404: + if response.status_code in [401, 404]: response = requests.get(REPO_URL, headers=HEADERS) if response.status_code != 200: abort_if_fail(response, "Unable to retrieve default branch")