Support the fragment form of Gerrit URLs

Some folks may copy the URL out of their brower location field
rather than using the permalink when creating a Gerrit Depends-On,
so support that as well.

Change-Id: Ie35fde41befcb0c5c062fcc0417afeed1cf60a77
This commit is contained in:
James E. Blair 2018-01-31 14:11:39 -08:00
parent ea398b5205
commit df31eb63cf
2 changed files with 8 additions and 2 deletions

View File

@ -54,8 +54,11 @@ class TestGerritCRD(ZuulTestCase):
A.setDependsOn(AM1, 1)
AM1.setDependsOn(AM2, 1)
# So that at least one test uses the /#/c/ form of the url,
# use it here.
url = 'https://%s/#/c/%s' % (B.gerrit.server, B.number)
A.data['commitMessage'] = '%s\n\nDepends-On: %s\n' % (
A.subject, B.data['url'])
A.subject, url)
self.fake_gerrit.addEvent(A.addApproval('Approved', 1))
self.waitUntilSettled()

View File

@ -54,7 +54,10 @@ class GerritSource(BaseSource):
parsed = urllib.parse.urlparse(url)
except ValueError:
return None
m = self.change_re.match(parsed.path)
path = parsed.path
if parsed.fragment:
path += '#' + parsed.fragment
m = self.change_re.match(path)
if not m:
return None
try: