Skip to content

Commit

Permalink
Bug fix repo name (moremoban#227)
Browse files Browse the repository at this point in the history
* 🐛 fix wrong repo name bug by using giturlparse package. resolves moremoban#226

* 🔥 remove moban from test requirements
  • Loading branch information
chfw authored Feb 19, 2019
1 parent 1497770 commit 9517891
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .moban.cd/moban.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ dependencies:
- appdirs==1.4.3
- crayons
- GitPython==2.1.11
- git-url-parse
- giturlparse
description: Yet another jinja2 cli command for static text generation
scm_host: github.com
8 changes: 5 additions & 3 deletions moban/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ def git_clone(requires):

def get_repo_name(repo_url):
import giturlparse
from giturlparse.parser import ParserError

try:
repo = giturlparse.parse(repo_url)
return repo.name
except ParserError:
name = repo.repo
if name.endswith('/'):
name = name[:-1]
return name
except AttributeError:
reporter.report_error_message(
constants.MESSAGE_INVALID_GIT_URL % repo_url
)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ lml>=0.0.9
appdirs==1.4.3
crayons
GitPython==2.1.11
git-url-parse
giturlparse
1 change: 0 additions & 1 deletion tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ codecov
coverage
mock
flake8
moban
black;python_version>="3.6"
isort;python_version>="3.6"
moban-handlebars
Expand Down
3 changes: 2 additions & 1 deletion tests/test_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,14 @@ def test_checkout_new_with_branch(

def test_get_repo_name():
repos = [
"https://github.com/sphinx-doc/sphinx",
"https://github.com/abc/repo",
"https://github.com/abc/repo.git",
"https://github.com/abc/repo/",
"git@github.com:moremoban/moban.git",
]
actual = [get_repo_name(repo) for repo in repos]
expected = ["repo", "repo", "repo", "moban"]
expected = ["sphinx", "repo", "repo", "repo", "moban"]
eq_(expected, actual)


Expand Down

0 comments on commit 9517891

Please sign in to comment.