Bugtracker: Add support for subprojects to GitLab tracker.
This commit is contained in:
@ -24,7 +24,7 @@ import supybot.world as world
|
||||
|
||||
from imp import reload
|
||||
|
||||
__version__ = "3.9.0"
|
||||
__version__ = "4.0.0"
|
||||
__author__ = supybot.Author("Krytarik Raido", "krytarik", "krytarik@tuxgarage.com")
|
||||
__contributors__ = {
|
||||
supybot.Author("Dennis Kaarsemaker", "Seveas", "dennis@kaarsemaker.net"): ['Original Author'],
|
||||
|
@ -530,8 +530,9 @@ class Bugtracker(callbacks.PluginRegexp):
|
||||
tracker = SourceForge().get_tracker(snarfurl)
|
||||
elif 'github.com' in snarfurl:
|
||||
tracker = GitHub().get_tracker(snarfurl)
|
||||
elif re.match(r'[^\s/]+/[^\s/]+/[^\s/]+/-/(issues|merge_requests)', snarfurl) \
|
||||
or re.match(r'[^\s/]+/[^\s/]+/[^\s/]+/merge_requests', snarfurl):
|
||||
elif re.match(r'[^\s/]+/[^\s/]+(/[^\s/]+)+/-/(issues|merge_requests)', snarfurl) \
|
||||
or re.match(r'[^\s/]+/[^\s/]+(/[^\s/]+)+/merge_requests', snarfurl) \
|
||||
or re.match(r'[^\s/]+/[^\s/]+(/[^\s/]+){2,}/issues', snarfurl):
|
||||
tracker = GitLab().get_tracker(snarfurl, bugid)
|
||||
elif re.match(r'[^\s/]+/[^\s/]+/[^\s/]+/issues', snarfurl):
|
||||
tracker = GitLab().get_tracker(snarfurl, bugid)
|
||||
@ -983,12 +984,12 @@ class GitHub(IBugtracker):
|
||||
class GitLab(IBugtracker):
|
||||
def get_tracker(self, url, bugid):
|
||||
try:
|
||||
match = re.match(r'[^\s/]+/[^\s/]+/[^\s/]+/(-/)?(issues|merge_requests)', url)
|
||||
match = re.match(r'[^\s/]+/(?P<project>[^\s/]+/[^\s/]+(/[^\s/]+)*?)/(-/)?(issues|merge_requests)', url)
|
||||
desc = match.group(0)
|
||||
name = desc.lower()
|
||||
url = 'https://%s' % desc
|
||||
bugurl = "%s/%d" % (re.sub(r'(://[^\s/]+)/([^\s/]+)/([^\s/]+)/(-/)?',
|
||||
r'\g<1>/api/v4/projects/\g<2>%2F\g<3>/', url), bugid)
|
||||
bugurl = "%s/%d" % (re.sub(r'(://[^\s/]+)/[^\s/]+(/[^\s/]+)+/(-/)?',
|
||||
r'\g<1>/api/v4/projects/%s/' % match.group('project').replace('/', '%2F'), url), bugid)
|
||||
bugjson = utils.web.getUrl(bugurl)
|
||||
bug = json.loads(bugjson.decode('utf-8'))
|
||||
return GitLab(name, url, desc, 'gitlab')
|
||||
@ -996,8 +997,9 @@ class GitLab(IBugtracker):
|
||||
pass
|
||||
|
||||
def get_bug(self, bugtype, bugid):
|
||||
url = "%s/%d" % (re.sub(r'(://[^\s/]+)/([^\s/]+)/([^\s/]+)/(-/)?',
|
||||
r'\g<1>/api/v4/projects/\g<2>%2F\g<3>/', self.url), bugid)
|
||||
match = re.match(r'[^\s:]+://[^\s/]+/(?P<project>[^\s/]+/[^\s/]+(/[^\s/]+)*?)/(-/)?(issues|merge_requests)', self.url)
|
||||
url = "%s/%d" % (re.sub(r'(://[^\s/]+)/[^\s/]+(/[^\s/]+)+/(-/)?',
|
||||
r'\g<1>/api/v4/projects/%s/' % match.group('project').replace('/', '%2F'), self.url), bugid)
|
||||
if bugtype in ('issue', 'bug'):
|
||||
url = url.replace('/merge_requests/', '/issues/')
|
||||
elif bugtype in ('merge', 'mr', 'pull', 'pr'):
|
||||
@ -1008,7 +1010,7 @@ class GitLab(IBugtracker):
|
||||
except Exception as e:
|
||||
raise BugtrackerError(self.errget % (self.description, e, url))
|
||||
try:
|
||||
product = '/'.join(self.url.split('/')[3:5])
|
||||
product = match.group('project')
|
||||
status = bug['state']
|
||||
if bug['assignees']:
|
||||
assino = len(bug['assignees'])
|
||||
|
Reference in New Issue
Block a user