summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-11-27 05:45:38 +0000
committerGerrit Code Review <review@openstack.org>2018-11-27 05:45:38 +0000
commitbe4dc6e9d20cf36ae6f7fb24cd3449e6655acb68 (patch)
tree479dcb206b271cb1088391f6d4a0113b6c95ba6d
parent1b83044ed4de01205ed54c1712da70f927fbb7c8 (diff)
parentdc4d6bc61c9ca23f4f8008a0eec5213d3449d2a9 (diff)
Merge "Add support for Gerrit v2.16's change URL schema"
-rw-r--r--tests/unit/test_gerrit_crd.py22
-rw-r--r--zuul/driver/gerrit/gerritsource.py2
2 files changed, 19 insertions, 5 deletions
diff --git a/tests/unit/test_gerrit_crd.py b/tests/unit/test_gerrit_crd.py
index 55746b2..cabaf7c 100644
--- a/tests/unit/test_gerrit_crd.py
+++ b/tests/unit/test_gerrit_crd.py
@@ -22,7 +22,7 @@ from tests.base import (
22class TestGerritCRD(ZuulTestCase): 22class TestGerritCRD(ZuulTestCase):
23 tenant_config_file = 'config/single-tenant/main.yaml' 23 tenant_config_file = 'config/single-tenant/main.yaml'
24 24
25 def test_crd_gate(self): 25 def _test_crd_gate(self, url_fmt):
26 "Test cross-repo dependencies" 26 "Test cross-repo dependencies"
27 A = self.fake_gerrit.addFakeChange('org/project1', 'master', 'A') 27 A = self.fake_gerrit.addFakeChange('org/project1', 'master', 'A')
28 B = self.fake_gerrit.addFakeChange('org/project2', 'master', 'B') 28 B = self.fake_gerrit.addFakeChange('org/project2', 'master', 'B')
@@ -52,9 +52,9 @@ class TestGerritCRD(ZuulTestCase):
52 A.setDependsOn(AM1, 1) 52 A.setDependsOn(AM1, 1)
53 AM1.setDependsOn(AM2, 1) 53 AM1.setDependsOn(AM2, 1)
54 54
55 # So that at least one test uses the /#/c/ form of the url, 55 url = url_fmt.format(baseurl=B.gerrit.baseurl.rstrip('/'),
56 # use it here. 56 project=B.project,
57 url = 'https://%s/#/c/%s' % (B.gerrit.server, B.number) 57 change_no=B.number)
58 A.data['commitMessage'] = '%s\n\nDepends-On: %s\n' % ( 58 A.data['commitMessage'] = '%s\n\nDepends-On: %s\n' % (
59 A.subject, url) 59 A.subject, url)
60 60
@@ -91,6 +91,20 @@ class TestGerritCRD(ZuulTestCase):
91 'project-merge', 'org/project1').changes 91 'project-merge', 'org/project1').changes
92 self.assertEqual(changes, '2,1 1,1') 92 self.assertEqual(changes, '2,1 1,1')
93 93
94 # Different versions of Gerrit have used 3 different URL schemata for
95 # changes - repeat the simple test on each of the 3 to ensure they can be
96 # parsed, the other tests just use the default URL schema provided in
97 # FakeGerritChange.data['url'] .
98
99 def test_crd_gate_url_schema1(self):
100 self._test_crd_gate('{baseurl}/{change_no}')
101
102 def test_crd_gate_url_schema2(self):
103 self._test_crd_gate('{baseurl}/#/c/{change_no}')
104
105 def test_crd_gate_url_schema3(self):
106 self._test_crd_gate('{baseurl}/c/{project}/+/{change_no}/')
107
94 def test_crd_gate_triangle(self): 108 def test_crd_gate_triangle(self):
95 A = self.fake_gerrit.addFakeChange('org/project1', 'master', 'A') 109 A = self.fake_gerrit.addFakeChange('org/project1', 'master', 'A')
96 B = self.fake_gerrit.addFakeChange('org/project2', 'master', 'B') 110 B = self.fake_gerrit.addFakeChange('org/project2', 'master', 'B')
diff --git a/zuul/driver/gerrit/gerritsource.py b/zuul/driver/gerrit/gerritsource.py
index c37d742..2c36d47 100644
--- a/zuul/driver/gerrit/gerritsource.py
+++ b/zuul/driver/gerrit/gerritsource.py
@@ -38,7 +38,7 @@ class GerritSource(BaseSource):
38 prefix_ui += '/' 38 prefix_ui += '/'
39 39
40 self.change_re = re.compile( 40 self.change_re = re.compile(
41 r"/%s(\#\/c\/)?(\d+)[\w]*" % prefix_ui) 41 r"/%s(\#\/c\/|c\/.*\/\+\/)?(\d+)[\w]*" % prefix_ui)
42 42
43 def getRefSha(self, project, ref): 43 def getRefSha(self, project, ref):
44 return self.connection.getRefSha(project, ref) 44 return self.connection.getRefSha(project, ref)