Skip to content

Commit 5b572a2

Browse files
committed
make GITHUB_TOKEN in lfs_probe a fallback rather than an override
1 parent 4d54c09 commit 5b572a2

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

misc/bazel/internal/git_lfs_probe.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,17 @@ def get_endpoint():
6868
# see https://github.com/actions/checkout/blob/44c2b7a8a4ea60a981eaca3cf939b5f4305c123b/src/git-auth-helper.ts#L56-L63
6969
auth = git("config", f"http.{url.scheme}://{url.netloc}/.extraheader")
7070
endpoint.update_headers(get_env(auth, sep=": "))
71-
if "GITHUB_TOKEN" in os.environ:
72-
endpoint.headers["Authorization"] = f"token {os.environ['GITHUB_TOKEN']}"
7371
if "Authorization" not in endpoint.headers:
74-
# last chance: use git credentials (possibly backed by a credential helper like the one installed by gh)
75-
# see https://git-scm.com/docs/git-credential
76-
credentials = get_env(git("credential", "fill", check=True,
77-
# drop leading / from url.path
78-
input=f"protocol={url.scheme}\nhost={url.netloc}\npath={url.path[1:]}\n"))
79-
auth = base64.b64encode(f'{credentials["username"]}:{credentials["password"]}'.encode()).decode('ascii')
80-
endpoint.headers["Authorization"] = f"Basic {auth}"
72+
if "GITHUB_TOKEN" in os.environ:
73+
endpoint.headers["Authorization"] = f"token {os.environ['GITHUB_TOKEN']}"
74+
else:
75+
# last chance: use git credentials (possibly backed by a credential helper like the one installed by gh)
76+
# see https://git-scm.com/docs/git-credential
77+
credentials = get_env(git("credential", "fill", check=True,
78+
# drop leading / from url.path
79+
input=f"protocol={url.scheme}\nhost={url.netloc}\npath={url.path[1:]}\n"))
80+
auth = base64.b64encode(f'{credentials["username"]}:{credentials["password"]}'.encode()).decode('ascii')
81+
endpoint.headers["Authorization"] = f"Basic {auth}"
8182
return endpoint
8283

8384

0 commit comments

Comments
 (0)