-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add support for ssh url repos (#416)
Co-authored-by: Tom Hu <[email protected]> Co-authored-by: joseph-sentry <[email protected]>
- Loading branch information
1 parent
241f999
commit 88b7c71
Showing
2 changed files
with
7 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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): | ||
|
@@ -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): | ||
|