Skip to content

Commit 88b7c71

Browse files
escarlsthomasrockhu-codecovjoseph-sentry
authored
fix: add support for ssh url repos (#416)
Co-authored-by: Tom Hu <88201630+thomasrockhu-codecov@users.noreply.github.com> Co-authored-by: joseph-sentry <136376984+joseph-sentry@users.noreply.github.com>
1 parent 241f999 commit 88b7c71

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

codecov_cli/helpers/git.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,16 @@ def parse_git_service(remote_repo_url: str):
6161
Possible cases we're considering:
6262
- https://github.com/codecov/codecov-cli.git returns github
6363
- git@github.com:codecov/codecov-cli.git returns github
64+
- ssh://git@github.com/gitcodecov/codecov-cli returns github
65+
- ssh://git@github.com:gitcodecov/codecov-cli returns github
6466
- https://user-name@bitbucket.org/namespace-codecov/first_repo.git returns bitbucket
6567
"""
6668
services = [service.value for service in GitService]
6769
parsed_url = urlparse(remote_repo_url)
6870
service = None
6971

70-
if remote_repo_url.startswith("https://"):
72+
scheme = parsed_url.scheme
73+
if scheme in ("https", "ssh"):
7174
netloc = parsed_url.netloc
7275
if "@" in netloc:
7376
netloc = netloc.split("@", 1)[1]

tests/helpers/test_git.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
("ssh://host.abc.xz/owner/repo.git", "owner/repo"),
5454
("user-name@host.xz:owner/repo.git/", "owner/repo"),
5555
("host.xz:owner/repo.git/", "owner/repo"),
56+
("ssh://git@github.com/gitcodecov/codecov-cli", "gitcodecov/codecov-cli"),
5657
],
5758
)
5859
def test_parse_slug_valid_address(address, slug):
@@ -107,6 +108,8 @@ def test_parse_slug_invalid_address(address):
107108
"bitbucket",
108109
),
109110
("git@bitbucket.org:name-codecov/abc.git.git", "bitbucket"),
111+
("ssh://git@github.com/gitcodecov/codecov-cli", "github"),
112+
("ssh://git@github.com:gitcodecov/codecov-cli", "github"),
110113
],
111114
)
112115
def test_parse_git_service_valid_address(address, git_service):

0 commit comments

Comments
 (0)