diff options
Diffstat (limited to 'vcsbrowsers.py')
-rw-r--r-- | vcsbrowsers.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/vcsbrowsers.py b/vcsbrowsers.py index ba33cb1..409c1dc 100644 --- a/vcsbrowsers.py +++ b/vcsbrowsers.py @@ -1,6 +1,7 @@ # convenience wrappers to construct links # into the webinterfaces of different VCSs +from builtins import object import re @@ -14,6 +15,24 @@ class VCSBrowser(object): def branch(self, branch): raise NotImplemented +class GitlabBrowser(VCSBrowser): + """ + Gitlab based repo browser + + URLs for gitlab: + e.g. http://salsa.debian.org/libvirt-team/libvirt.git + """ + repotype = "gitweb" + + def __init__(self, url): + VCSBrowser.__init__(self, url) + + @classmethod + def check(cls, url): + return True if 'https://salsa.debian.org/' in url else False + + def commit(self, commitid): + return "%s/commit/%s" % (self.url, commitid) class GitWebBrowser(VCSBrowser): """ @@ -59,7 +78,7 @@ def guess_git_repo(url): >>> guess_git_repo("http://example.com/bar/foo").repotype 'cgit' """ - for repotype in [CGitBrowser, GitWebBrowser]: + for repotype in [GitlabBrowser, CGitBrowser, GitWebBrowser]: if repotype.check(url): return repotype(url) return CGitBrowser(url) |