-
-
Notifications
You must be signed in to change notification settings - Fork 562
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Philippe Ombredanne <[email protected]>
- Loading branch information
1 parent
8186fa1
commit 6741eaa
Showing
2 changed files
with
13 additions
and
4 deletions.
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# | ||
# Copyright (c) 2015 nexB Inc. and others. All rights reserved. | ||
# Copyright (c) 2017 nexB Inc. and others. All rights reserved. | ||
# http://nexb.com and https://github.com/nexB/scancode-toolkit/ | ||
# The ScanCode software is licensed under the Apache License version 2.0. | ||
# Data generated with ScanCode require an acknowledgment. | ||
|
@@ -75,8 +75,12 @@ def parse_repo_url(repo_url): | |
return repo_url | ||
|
||
if repo_url.startswith('git@'): | ||
left, right = repo_url.split('@', 1) | ||
host, repo = right.split(':', 1) | ||
left, _, right = repo_url.partition('@') | ||
if ':' in repo_url: | ||
host, _, repo = right.partition(':') | ||
else: | ||
# [email protected]/Filirom1/npm2aur.git | ||
host, _, repo = right.partition('/') | ||
if any(h in host for h in ['github', 'bitbucket', 'gitlab']): | ||
return 'https://%(host)s/%(repo)s' % locals() | ||
else: | ||
|
@@ -89,7 +93,7 @@ def parse_repo_url(repo_url): | |
'gitlab': 'https://gitlab.com/%(repo)s', | ||
'gist': 'https://gist.github.com/%(repo)s', | ||
} | ||
hoster, repo = repo_url.split(':', 1) | ||
hoster, _, repo = repo_url.partition(':') | ||
return hoster_urls[hoster] % locals() | ||
elif len(repo_url.split('/')) == 2: | ||
# implicit github | ||
|
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 |
---|---|---|
|
@@ -101,3 +101,8 @@ def test_parse_repo_url_13(self): | |
test = '[email protected]:foo/private.git' | ||
expected = 'https://gitlab.com/foo/private.git' | ||
assert expected == parse_repo_url(test) | ||
|
||
def test_parse_git_repo_url_without_slash_slash(self): | ||
test = '[email protected]/Filirom1/npm2aur.git' | ||
expected = 'https://github.com/Filirom1/npm2aur.git' | ||
assert expected == parse_repo_url(test) |