Skip to content

Commit 17dbefa

Browse files
author
Li
committed
#429 Utils: Add 'gist github' support and update test case
1 parent 2770730 commit 17dbefa

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/packagedcode/utils.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,12 @@ def parse_repo_url(repo_url):
8282
else:
8383
return repo_url
8484

85-
if repo_url.startswith('gist:'):
86-
return repo_url
87-
88-
elif repo_url.startswith(('bitbucket:', 'gitlab:', 'github:')):
85+
if repo_url.startswith(('bitbucket:', 'gitlab:', 'github:', 'gist:')):
8986
hoster_urls = {
9087
'bitbucket': 'https://bitbucket.org/%(repo)s',
9188
'github': 'https://github.com/%(repo)s',
9289
'gitlab': 'https://gitlab.com/%(repo)s',
90+
'gist': 'https://gist.github.com/%(repo)s',
9391
}
9492
hoster, repo = repo_url.split(':', 1)
9593
return hoster_urls[hoster] % locals()

tests/packagedcode/test_utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ class TestUtilsPi(FileBasedTesting):
3535
test_data_dir = os.path.join(os.path.dirname(__file__), 'data')
3636

3737
def test_parse_url(self):
38-
inputs = ['gist:11081aaa281',
38+
inputs = ['npm/npm',
39+
'gist:11081aaa281',
3940
'bitbucket:example/repo',
4041
'gitlab:another/repo',
4142
'expressjs/serve-static',
@@ -52,7 +53,8 @@ def test_parse_url(self):
5253
results = []
5354
for input in inputs:
5455
results.append(parse_repo_url(input))
55-
expected = ['gist:11081aaa281',
56+
expected = ['https://github.com/npm/npm',
57+
'https://gist.github.com/11081aaa281',
5658
'https://bitbucket.org/example/repo',
5759
'https://gitlab.com/another/repo',
5860
'https://github.com/expressjs/serve-static',

0 commit comments

Comments
 (0)