Check whether patches returned by Gerrit queries in fact match the query.

If the Pre-CQ launcher picks up a CL while the CQ is committing
the CL, it may catch a race condition where a new patchset has been
created and committed by the CQ, but the CL is still treated as if
it matches the query (which it doesn't, anymore).

See https://gerrit.chromium.org/gerrit/#/c/48712 for an example.

To fix this, we add logic to the CQ to check whether the currentPatchSet
for the CL still matches the query. This only works when we don't have a
custom query.

In cases where the user has specified a custom query for testing, we
really don't care about checking for this race condition, because this
is just for testing purposes and it would be difficult to implement
verification of arbitrary queries.

BUG=chromium:235459
TEST=Test run of mario-paladin.

Change-Id: I3e4eafa22300631310e56429aabe9b01dd1a7440
Reviewed-on: https://gerrit.chromium.org/gerrit/49191
Commit-Queue: David James <davidjames@chromium.org>
Reviewed-by: David James <davidjames@chromium.org>
Tested-by: David James <davidjames@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49260
Reviewed-by: Ryan Cui <rcui@chromium.org>
3 files changed