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
diff --git a/tests/unit/test_gerrit_crd.py b/tests/unit/test_gerrit_crd.py
index a8924b9..ad25c47 100644
--- a/tests/unit/test_gerrit_crd.py
+++ b/tests/unit/test_gerrit_crd.py
@@ -54,8 +54,11 @@
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()
diff --git a/zuul/driver/gerrit/gerritsource.py b/zuul/driver/gerrit/gerritsource.py
index 9e327b9..fdc1ad7 100644
--- a/zuul/driver/gerrit/gerritsource.py
+++ b/zuul/driver/gerrit/gerritsource.py
@@ -54,7 +54,10 @@
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: