Skip to content

Commit e9d9b56

Browse files
committed
Merge pull request #4 from yakky/gitlab
Add support for gitlab
2 parents 1fed2dd + 1802cc5 commit e9d9b56

File tree

5 files changed

+56
-0
lines changed

5 files changed

+56
-0
lines changed

giturlparse/parser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
'repo',
99
'owner',
1010
'_user',
11+
'port',
1112

1213
'url',
1314
'platform',
@@ -18,6 +19,7 @@
1819
def parse(url, check_domain=True):
1920
# Values are None by default
2021
parsed_info = defaultdict(lambda: None)
22+
parsed_info['port'] = ''
2123

2224
# Defaults to all attributes
2325
map(parsed_info.setdefault, SUPPORTED_ATTRIBUTES)

giturlparse/platforms/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from .bitbucket import BitbucketPlatform
55
from .friendcode import FriendCodePlatform
66
from .assembla import AssemblaPlatform
7+
from .gitlab import GitlabPlatform
78

89

910
# Supported platforms
@@ -13,6 +14,7 @@
1314
('bitbucket', BitbucketPlatform()),
1415
('friendcode', FriendCodePlatform()),
1516
('assembla', AssemblaPlatform()),
17+
('gitlab', GitlabPlatform()),
1618

1719
# Match url
1820
('base', BasePlatform()),

giturlparse/result.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ def friendcode(self):
106106
def assembla(self):
107107
return self.platform == 'assembla'
108108

109+
@property
110+
def gitlab(self):
111+
return self.platform == 'gitlab'
112+
109113
##
110114
# Get data as dict
111115
##

giturlparse/tests/parse.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,44 @@
5050
'protocol': 'ssh',
5151
'platform': 'bitbucket'
5252
})),
53+
54+
# Gitlab
55+
('SSH', ('git@host.org:9999/Org/Repo.git', {
56+
'host': 'host.org',
57+
'user': 'git',
58+
'owner': 'Org',
59+
'repo': 'Repo',
60+
61+
'protocol': 'ssh',
62+
'platform': 'gitlab'
63+
})),
64+
('SSH', ('git@host.org:Org/Repo.git', {
65+
'host': 'host.org',
66+
'user': 'git',
67+
'owner': 'Org',
68+
'repo': 'Repo',
69+
70+
'protocol': 'ssh',
71+
'platform': 'gitlab'
72+
})),
73+
('SSH', ('ssh://git@host.org:9999/Org/Repo.git', {
74+
'host': 'host.org',
75+
'user': 'git',
76+
'owner': 'Org',
77+
'repo': 'Repo',
78+
79+
'protocol': 'ssh',
80+
'platform': 'gitlab'
81+
})),
82+
('HTTPS', ('https://host.org/Org/Repo.git', {
83+
'host': 'host.org',
84+
'user': 'git',
85+
'owner': 'Org',
86+
'repo': 'Repo',
87+
88+
'protocol': 'https',
89+
'platform': 'gitlab'
90+
})),
5391
)
5492

5593
INVALID_PARSE_URLS = (

giturlparse/tests/rewrite.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@
3838

3939
# FriendCode HTTPS
4040
('https://friendco.de/Aaron@user/test-repo.git', 'https', 'https://friendco.de/Aaron@user/test-repo.git'),
41+
42+
# Gitlab SSH
43+
('git@host.org:Org/Repo.git', 'ssh', 'ssh://git@host.org:Org/Repo.git'),
44+
('git@host.org:9999/Org/Repo.git', 'ssh', 'ssh://git@host.org:9999/Org/Repo.git'),
45+
('git@host.org:Org/Repo.git', 'https', 'https://host.org/Org/Repo.git'),
46+
('git@host.org:9999/Org/Repo.git', 'https', 'https://host.org/Org/Repo.git'),
47+
48+
# Gitlab HTTPS
49+
('https://host.org/Org/Repo.git', 'ssh', 'ssh://git@host.org:Org/Repo.git'),
50+
('https://host.org/Org/Repo.git', 'https', 'https://host.org/Org/Repo.git'),
4151
)
4252

4353
INVALID_PARSE_URLS = (

0 commit comments

Comments
 (0)