Just check that ref has changed when merging.
Record the sha at refs/head/branch before each report. Then if isMerged is called, just check that the sha has _changed_ since then, and if it has, assume that means it has reached the replica. This handles the case of a merge or cherry-pick commit being the actual commit that ends up at the ref, without the overhead of fetching and parsing that commit to see if it's really the change. This should be sufficient as long as Zuul is the only thing triggering merges. Change-Id: I50cfa7b4c011d9fd108046914c7bd236858ff5d3 Reviewed-on: https://review.openstack.org/10970 Reviewed-by: Clark Boylan <clark.boylan@gmail.com> Approved: James E. Blair <corvus@inaugust.com> Tested-by: Jenkins
This commit is contained in:
parent
4aea70c1de
commit
90f177df07
|
@ -109,6 +109,9 @@ class Gerrit(object):
|
|||
self.log.debug("No action specified; not reporting")
|
||||
return
|
||||
changeid = '%s,%s' % (change.number, change.patchset)
|
||||
ref = 'refs/heads/' + change.branch
|
||||
change._ref_sha = self.getRefSha(change.project.name,
|
||||
ref)
|
||||
return self.gerrit.review(change.project.name, changeid,
|
||||
message, action)
|
||||
|
||||
|
@ -123,6 +126,16 @@ class Gerrit(object):
|
|||
ret[ref] = revision
|
||||
return ret
|
||||
|
||||
def getRefSha(self, project, ref):
|
||||
refs = {}
|
||||
try:
|
||||
refs = self._getInfoRefs(project)
|
||||
except:
|
||||
self.log.exception("Exception looking for ref %s" %
|
||||
ref)
|
||||
sha = refs.get(ref, '')
|
||||
return sha
|
||||
|
||||
def isMerged(self, change, head=None):
|
||||
self.log.debug("Checking if change %s is merged" % change)
|
||||
if not change.number:
|
||||
|
@ -139,18 +152,12 @@ class Gerrit(object):
|
|||
if not change.is_merged:
|
||||
return False
|
||||
# Wait for the ref to show up in the repo
|
||||
head = 'refs/heads/' + head
|
||||
ref = 'refs/heads/' + change.branch
|
||||
self.log.debug("Waiting for %s to appear in git repo" % (change))
|
||||
start = time.time()
|
||||
while time.time() - start < self.replication_timeout:
|
||||
refs = {}
|
||||
try:
|
||||
refs = self._getInfoRefs(change.project.name)
|
||||
except:
|
||||
self.log.exception("Exception looking for ref in head %s" %
|
||||
head)
|
||||
ref = refs.get(head, '')
|
||||
if change._data['currentPatchSet']['revision'] == ref:
|
||||
sha = self.getRefSha(change.project.name, ref)
|
||||
if change._ref_sha != sha:
|
||||
self.log.debug("Change %s is in the git repo" %
|
||||
(change))
|
||||
return True
|
||||
|
|
Loading…
Reference in New Issue