summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/base.py9
-rw-r--r--zuul/driver/gerrit/gerritreporter.py25
2 files changed, 29 insertions, 5 deletions
diff --git a/tests/base.py b/tests/base.py
index b72bf8380..5a85ea0d7 100644
--- a/tests/base.py
+++ b/tests/base.py
@@ -1079,6 +1079,7 @@ class GerritWebServer(object):
# One of the changes in this topic isn't
# ready to merge
return self._409()
+ changes_to_merge = set(change.data['number'])
if fake_gerrit._fake_submit_whole_topic:
results = fake_gerrit._test_get_submitted_together(change)
for record in results:
@@ -1088,11 +1089,13 @@ class GerritWebServer(object):
# One of the changes in this topic isn't
# ready to merge
return self._409()
+ changes_to_merge.add(candidate.data['number'])
message = None
labels = {}
- fake_gerrit._test_handle_review(
- int(change.data['number']), message, True, labels,
- False, True)
+ for change_number in changes_to_merge:
+ fake_gerrit._test_handle_review(
+ int(change_number), message, True, labels,
+ False, True)
self.send_response(200)
self.end_headers()
diff --git a/zuul/driver/gerrit/gerritreporter.py b/zuul/driver/gerrit/gerritreporter.py
index 984b8742a..b99133dce 100644
--- a/zuul/driver/gerrit/gerritreporter.py
+++ b/zuul/driver/gerrit/gerritreporter.py
@@ -16,6 +16,7 @@ import logging
import voluptuous as v
from zuul.driver.gerrit.gerritsource import GerritSource
+from zuul.driver.gerrit.gerritmodel import GerritChange
from zuul.lib.logutil import get_annotated_logger
from zuul.model import Change
from zuul.reporter import BaseReporter
@@ -65,8 +66,28 @@ class GerritReporter(BaseReporter):
log.debug("Report change %s, params %s, message: %s, comments: %s",
item.change, self.config, message, comments)
- item.change._ref_sha = item.change.project.source.getRefSha(
- item.change.project, 'refs/heads/' + item.change.branch)
+ if phase2 and self._submit and not hasattr(item.change, '_ref_sha'):
+ # If we're starting to submit a bundle, save the current
+ # ref sha for every item in the bundle.
+ changes = set([item.change])
+ if item.bundle:
+ for i in item.bundle.items:
+ changes.add(i.change)
+
+ # Store a dict of project,branch -> sha so that if we have
+ # duplicate project/branches, we only query once.
+ ref_shas = {}
+ for other_change in changes:
+ if not isinstance(other_change, GerritChange):
+ continue
+ key = (other_change.project, other_change.branch)
+ ref_sha = ref_shas.get(key)
+ if not ref_sha:
+ ref_sha = other_change.project.source.getRefSha(
+ other_change.project,
+ 'refs/heads/' + other_change.branch)
+ ref_shas[key] = ref_sha
+ other_change._ref_sha = ref_sha
return self.connection.review(item, message, self._submit,
self._labels, self._checks_api,