gerrit: Add some quoting in 'gerrit query' commands

In case the values being queried in 'gerrit query' commands contain
special characters, they should be quoted - see:
https://gerrit-review.googlesource.com/Documentation/user-search.html#_argument_quoting

In particular, this fixes getChangesDependingOn when the Gerrit URL
contains a port specification and therefore a ':'.

This doesn't bother adding quoting for fields like "change:" which
certainly shouldn't have any such special chars.

In order to get this to pass tests deterministically, it was
necessary to fix an off-by-one error in the
FakeGerritConnection.simpleQuery logic that strips off the parens
from a compound query with "OR"s.

Change-Id: Idbd6b03f0d86cdf24290fa5020686f684fc7e4e3
This commit is contained in:
Brendan Jackman
2019-04-04 12:33:10 +07:00
parent 99c6617454
commit 918374315b
4 changed files with 9 additions and 6 deletions

View File

@@ -215,7 +215,7 @@ class TestZuulTriggerProjectChangeMerged(ZuulTestCase):
"current state of its repository. Please rebase the change and "
"upload a new patchset.")
self.assertTrue("project:org/project status:open" in
self.assertTrue("project:{org/project} status:open" in
self.fake_gerrit.queries)
# Reconfigure and run the test again. This is a regression
@@ -241,5 +241,5 @@ class TestZuulTriggerProjectChangeMerged(ZuulTestCase):
"dependencies was unable to be automatically merged with the "
"current state of its repository. Please rebase the change and "
"upload a new patchset.")
self.assertIn("project:org/project status:open",
self.assertIn("project:{org/project} status:open",
self.fake_gerrit.queries)