Skip to content

Commit

Permalink
fix: add support for ssh url repos (#416)
Browse files Browse the repository at this point in the history
Co-authored-by: Tom Hu <[email protected]>
Co-authored-by: joseph-sentry <[email protected]>
  • Loading branch information
3 people authored Apr 26, 2024
1 parent 241f999 commit 88b7c71
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion codecov_cli/helpers/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,16 @@ def parse_git_service(remote_repo_url: str):
Possible cases we're considering:
- https://github.com/codecov/codecov-cli.git returns github
- [email protected]:codecov/codecov-cli.git returns github
- ssh://[email protected]/gitcodecov/codecov-cli returns github
- ssh://[email protected]:gitcodecov/codecov-cli returns github
- https://[email protected]/namespace-codecov/first_repo.git returns bitbucket
"""
services = [service.value for service in GitService]
parsed_url = urlparse(remote_repo_url)
service = None

if remote_repo_url.startswith("https://"):
scheme = parsed_url.scheme
if scheme in ("https", "ssh"):
netloc = parsed_url.netloc
if "@" in netloc:
netloc = netloc.split("@", 1)[1]
Expand Down
3 changes: 3 additions & 0 deletions tests/helpers/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
("ssh://host.abc.xz/owner/repo.git", "owner/repo"),
("[email protected]:owner/repo.git/", "owner/repo"),
("host.xz:owner/repo.git/", "owner/repo"),
("ssh://[email protected]/gitcodecov/codecov-cli", "gitcodecov/codecov-cli"),
],
)
def test_parse_slug_valid_address(address, slug):
Expand Down Expand Up @@ -107,6 +108,8 @@ def test_parse_slug_invalid_address(address):
"bitbucket",
),
("[email protected]:name-codecov/abc.git.git", "bitbucket"),
("ssh://[email protected]/gitcodecov/codecov-cli", "github"),
("ssh://[email protected]:gitcodecov/codecov-cli", "github"),
],
)
def test_parse_git_service_valid_address(address, git_service):
Expand Down

0 comments on commit 88b7c71

Please sign in to comment.