Skip to content

Commit a6901cf

Browse files
authored
Merge pull request #38 from jayvdb/git-at-ports
Support ports for git@ URLs
2 parents 98a5377 + 22a11b3 commit a6901cf

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

giturlparse/parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@
5151
r'(?P<pathname>(\/(?P<owner>\w+)/)?'
5252
r'(\/?(?P<name>[\w\-]+)(\.git)?)?)$'),
5353
re.compile(r'^(?:(?P<user>.+)@)*'
54-
r'(?P<resource>[a-z0-9_.-]*)[:/]*'
54+
r'(?P<resource>[a-z0-9_.-]*)[:]*'
5555
r'(?P<port>[\d]+){0,1}'
56-
r'[:](?P<pathname>\/?(?P<owner>.+)/(?P<name>.+).git)$'),
56+
r'(?P<pathname>\/?(?P<owner>.+)/(?P<name>.+).git)$'),
5757
re.compile(r'((?P<user>\w+)@)?'
5858
r'((?P<resource>[\w\.\-]+))'
5959
r'[\:\/]{1,2}'

test/conftest.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,17 @@ def second_match_urls():
277277
'name': 'repo',
278278
'owner': 'owner',
279279
},
280+
'git+ssh://example.com:9999/owner/repo.git': {
281+
'pathname': '/owner/repo.git',
282+
'protocols': ['git', 'ssh'],
283+
'protocol': 'ssh',
284+
'href': 'git+ssh://example.com:9999/owner/repo.git',
285+
'resource': 'example.com',
286+
'user': None,
287+
'port': '9999',
288+
'name': 'repo',
289+
'owner': 'owner',
290+
},
280291
'git+https://example.com/owner/repo.git': {
281292
'pathname': '/owner/repo.git',
282293
'protocols': ['git', 'https'],
@@ -288,6 +299,17 @@ def second_match_urls():
288299
'name': 'repo',
289300
'owner': 'owner',
290301
},
302+
'git+https://example.com:9999/owner/repo.git': {
303+
'pathname': '/owner/repo.git',
304+
'protocols': ['git', 'https'],
305+
'protocol': 'https',
306+
'href': 'git+https://example.com:9999/owner/repo.git',
307+
'resource': 'example.com',
308+
'user': None,
309+
'port': '9999',
310+
'name': 'repo',
311+
'owner': 'owner',
312+
},
291313
}
292314

293315

@@ -327,6 +349,18 @@ def third_match_urls():
327349
'name': 'repo',
328350
'owner': 'owner',
329351
},
352+
# GitLab
353+
'user@foo-example.com:9999/owner/repo.git': {
354+
'pathname': '/owner/repo.git',
355+
'protocols': [],
356+
'protocol': 'ssh',
357+
'href': 'user@foo-example.com:9999/owner/repo.git',
358+
'resource': 'foo-example.com',
359+
'user': 'user',
360+
'port': '9999',
361+
'name': 'repo',
362+
'owner': 'owner',
363+
},
330364
}
331365

332366

0 commit comments

Comments
 (0)