Skip to content

Commit 51b000a

Browse files
authored
Merge pull request github#16649 from github/redsun82/bazel-lfs
Bazel: ignore non-default SSH endpoints in `git_lfs_probe.py`
2 parents 0173cf5 + 8479673 commit 51b000a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

misc/bazel/internal/git_lfs_probe.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,18 @@ def git(*args, **kwargs):
5757

5858

5959
def get_endpoint():
60-
lfs_env = get_env(subprocess.check_output(["git", "lfs", "env"], text=True, cwd=source_dir))
61-
endpoint = next(v for k, v in lfs_env.items() if k.startswith('Endpoint'))
60+
lfs_env_items = iter(get_env(subprocess.check_output(["git", "lfs", "env"], text=True, cwd=source_dir)).items())
61+
endpoint = next(v for k, v in lfs_env_items if k.startswith('Endpoint'))
6262
endpoint, _, _ = endpoint.partition(' ')
63-
ssh_endpoint = lfs_env.get(" SSH")
63+
# only take the ssh endpoint if it follows directly after the first endpoint we found
64+
# in a situation like
65+
# Endpoint (a)=...
66+
# Endpoint (b)=...
67+
# SSH=...
68+
# we want to ignore the SSH endpoint, as it's not linked to the default (a) endpoint
69+
following_key, following_value = next(lfs_env_items, (None, None))
70+
ssh_endpoint = following_value if following_key == " SSH" else None
71+
6472
endpoint = Endpoint(endpoint, {
6573
"Content-Type": "application/vnd.git-lfs+json",
6674
"Accept": "application/vnd.git-lfs+json",

0 commit comments

Comments
 (0)