Skip to content

Commit 26aaee6

Browse files
committed
support TFS git URLs
improving the regex to parse more exotic URLs. Signed-off-by: André Roth <[email protected]>
1 parent d3eac95 commit 26aaee6

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

giturlparse/parser.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,11 @@
3737

3838
POSSIBLE_REGEXES = (
3939
re.compile(r'^(?P<protocol>https?|git|ssh|rsync)\://'
40-
r'(?:(?P<user>.+)@)*'
41-
r'(?P<resource>[a-z0-9_.-]*)'
42-
r'[:/]*'
43-
r'(?P<port>[\d]+){0,1}'
44-
r'(?P<pathname>\/((?P<owner>[\w\-]+)\/)?'
45-
r'((?P<name>[\w\-\.]+?)(\.git|\/)?)?)$'),
40+
r'(?:(?P<user>[^@]+)@)?'
41+
r'(?P<resource>[^\/:]+)'
42+
r'(:?(?P<port>\d+))?'
43+
r'(?P<pathname>\/((?P<owner>[\w\-\.\/]+)\/)?'
44+
r'(?P<name>[^\/]+?)(\.git|\/)?)$'),
4645
re.compile(r'(git\+)?'
4746
r'((?P<protocol>\w+)://)'
4847
r'((?P<user>\w+)@)?'

test/conftest.py

+11
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,17 @@ def first_match_urls():
315315
'name': 'Stouts.openvpn',
316316
'owner': 'tterranigma',
317317
},
318+
'ssh://someserver.com/tfs/SomeWhere/My.Project/_git/somerepo': {
319+
'pathname': '/tfs/SomeWhere/My.Project/_git/somerepo',
320+
'protocols': ['ssh'],
321+
'protocol': 'ssh',
322+
'href': 'ssh://someserver.com/tfs/SomeWhere/My.Project/_git/somerepo',
323+
'resource': 'someserver.com',
324+
'user': None,
325+
'port': None,
326+
'name': 'somerepo',
327+
'owner': 'tfs/SomeWhere/My.Project/_git',
328+
},
318329
}
319330

320331

0 commit comments

Comments
 (0)