Retry git fetches to work around GitPython bug.

GitPython when fetching refs may improperly read in git progress info
and interpret it as fetch info. When this happens an AssertionError is
thrown. However, since fetching seems to cache the ref locally
subsequent fetches work without running into the progress info problem.
So fetch again if an AssertionError is caught.

Upstream bugfix
https://github.com/gitpython-developers/GitPython/pull/42

Change-Id: I1768b836aade2853d4dd3b2f4cd1fce7ec035524
Reviewed-on: https://review.openstack.org/15219
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Reviewed-by: James E. Blair <corvus@inaugust.com>
Approved: Clark Boylan <clark.boylan@gmail.com>
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Tested-by: Jenkins
changes/27/15927/1
Clark Boylan 11 years ago committed by Jenkins
parent ce333845ea
commit 14b5537607

@ -65,16 +65,25 @@ class Repo(object):
def cherryPick(self, ref):
self.log.debug("Cherry-picking %s" % ref)
origin = self.repo.remotes.origin
origin.fetch(ref)
self.fetch(ref)
self.repo.git.cherry_pick("FETCH_HEAD")
def merge(self, ref):
self.log.debug("Merging %s" % ref)
origin = self.repo.remotes.origin
origin.fetch(ref)
self.fetch(ref)
self.repo.git.merge("FETCH_HEAD")
def fetch(self, ref):
# The git.remote.fetch method may read in git progress info and
# interpret it improperly causing an AssertionError. Because the
# data was fetched properly subsequent fetches don't seem to fail.
# So try again if an AssertionError is caught.
origin = self.repo.remotes.origin
try:
origin.fetch(ref)
except AssertionError:
origin.fetch(ref)
def createZuulRef(self, ref):
ref = ZuulReference.create(self.repo, ref, 'HEAD')
return ref

Loading…
Cancel
Save