Skip to content

Commit

Permalink
Added GitLab support.
Browse files Browse the repository at this point in the history
  • Loading branch information
allenh1 committed Jun 2, 2017
1 parent c2b9271 commit abdf862
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/rosdistro/rosdistro.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ def __init__(self, name, repository):

def _fetch_package_xml(self, rosdistro):
repo = self.repository
supported_non_githubs = [ 'gitlab', 'bitbucket' ]

if 'github.com' in repo.url:
url = repo.url
release_tag = 'release/{0}/{1}/{2}'.format(rosdistro, self.name, repo.version)
Expand All @@ -222,7 +224,31 @@ def _fetch_package_xml(self, rosdistro):
self._release_tags[rosdistro] = release_tag
return package_xml, release_tag
else:
raise Exception("Non-github repositories are net yet supported by the rosdistro tool")
for nongithub in supported_non_githubs:
try:
if nongithub == 'gitlab':
"""
GitLab
"""
info('Trying to fetch non-github repository as a GitLab instance...')
url = repo.url
release_tag = 'release/{0}/{1}/{2}'.format(rosdistro, self.name, repo.version)
url = url.replace('.git', '/raw/{0}/package.xml'.format(release_tag))
elif nongithub == 'bitbucket':
"""
BitBucket
"""
raise RuntimeError('todo: bitbucket support')
package_xml = urlopen(url).read()
self._package_xmls[rosdistro] = package_xml
self._release_tags[rosdistro] = release_tag
return package_xml, release_tag
except Exception as e:
info('Package is not in a {0} repo...'.format({
'gitlab' : 'GitLab',
'bitbucket' : 'BitBucket'
}[nongithub]))
raise Exception('Failed to identify non-github repository type!')

def get_package_xml(self, rosdistro):
if rosdistro not in self._package_xmls:
Expand Down

0 comments on commit abdf862

Please sign in to comment.