Skip to content

Commit

Permalink
support TFS git URLs
Browse files Browse the repository at this point in the history
improving the regex to parse more exotic URLs.

Signed-off-by: André Roth <[email protected]>
  • Loading branch information
neolynx committed Feb 2, 2020
1 parent d3eac95 commit c19812b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
11 changes: 5 additions & 6 deletions giturlparse/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,11 @@

POSSIBLE_REGEXES = (
re.compile(r'^(?P<protocol>https?|git|ssh|rsync)\://'
r'(?:(?P<user>.+)@)*'
r'(?P<resource>[a-z0-9_.-]*)'
r'[:/]*'
r'(?P<port>[\d]+){0,1}'
r'(?P<pathname>\/((?P<owner>[\w\-]+)\/)?'
r'((?P<name>[\w\-\.]+?)(\.git|\/)?)?)$'),
r'(?:(?P<user>[^@]+)@)?'
r'(?P<resource>[^\/:]+)'
r'(:?(?P<port>\d+))?'
r'(?P<pathname>\/((?P<owner>[\w\-\.\/]+)\/)?'
r'(?P<name>[^\/]+?)(\.git|\/)?)$'),
re.compile(r'(git\+)?'
r'((?P<protocol>\w+)://)'
r'((?P<user>\w+)@)?'
Expand Down
12 changes: 12 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,18 @@ def first_match_urls():
'name': 'Stouts.openvpn',
'owner': 'tterranigma',
},
'ssh://someserver.com/tfs/SomeWhere/My.Project/_git/somerepo': {
'pathname': '/tfs/SomeWhere/My.Project/_git/somerepo',
'protocols': ['ssh'],
'protocol': 'ssh',
'href':
'ssh://someserver.com/tfs/SomeWhere/My.Project/_git/somerepo',
'resource': 'someserver.com',
'user': None,
'port': None,
'name': 'somerepo',
'owner': 'tfs/SomeWhere/My.Project/_git',
},
}


Expand Down

0 comments on commit c19812b

Please sign in to comment.