Skip to content

Commit 1acf2d8

Browse files
lcianclaude
andcommitted
fix: Handle SSH-style GitHub URLs in dependency fetching
parse_repo_path only handled HTTPS URLs (https://github.com/owner/repo) and raised ValueError for SSH URLs (git@github.com:owner/repo). This broke dependency resolution for any devservices config using SSH-style repo_link values (e.g. vroom's reference to sentry-shared-kafka). Extend the parser to also split on 'github.com:' for the SSH format. Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
1 parent 007d792 commit 1acf2d8

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

devservices/utils/github.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,17 @@
1616

1717

1818
def parse_repo_path(repo_link: str) -> str:
19-
"""Extract the "owner/repo" path from a GitHub URL."""
19+
"""Extract the "owner/repo" path from a GitHub URL.
20+
21+
Handles both HTTPS (https://github.com/owner/repo) and SSH
22+
(git@github.com:owner/repo) formats.
23+
"""
2024
url = repo_link.rstrip("/").removesuffix(".git")
21-
if "github.com/" not in url:
22-
raise ValueError(f"Not a GitHub URL: {repo_link}")
23-
return url.split("github.com/", 1)[1]
25+
if "github.com/" in url:
26+
return url.split("github.com/", 1)[1]
27+
if "github.com:" in url:
28+
return url.split("github.com:", 1)[1]
29+
raise ValueError(f"Not a GitHub URL: {repo_link}")
2430

2531

2632
def zipball_url(repo_path: str, ref: str) -> str:

tests/utils/test_github.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ def test_parse_repo_path_valid() -> None:
2828
assert github.parse_repo_path("http://github.com/org/repo") == "org/repo"
2929

3030

31+
def test_parse_repo_path_ssh() -> None:
32+
assert (
33+
github.parse_repo_path("git@github.com:getsentry/test-repo")
34+
== "getsentry/test-repo"
35+
)
36+
assert (
37+
github.parse_repo_path("git@github.com:getsentry/test-repo.git")
38+
== "getsentry/test-repo"
39+
)
40+
41+
3142
def test_parse_repo_path_non_github() -> None:
3243
with pytest.raises(ValueError):
3344
github.parse_repo_path("file:///path/to/repo")

0 commit comments

Comments
 (0)