Permalink
Browse files

Merge djmitche/buildbot:8/git-clone-failure (PR #1057)

  • Loading branch information...
djmitche committed Jan 22, 2014
2 parents 7ba629d + 4ce20c6 commit 2979c5eb803f8f1d217da4c29f1cde8c7812f3b3
Showing with 48 additions and 12 deletions.
  1. +19 −11 master/buildbot/steps/source/git.py
  2. +29 −1 master/buildbot/test/unit/test_steps_source_git.py
@@ -237,10 +237,12 @@ def clean(self):
d.addCallback(self._cleanSubmodule)
return d
@defer.inlineCallbacks
def clobber(self):
d = self._doClobber()
d.addCallback(lambda _: self._fullClone(shallowClone=self.shallow))
return d
yield self._doClobber()
res = yield self._fullClone(shallowClone=self.shallow)
if res != 0:
raise buildstep.BuildStepFailed
def fresh(self):
command = ['clean', '-f', '-f', '-d', '-x']
@@ -444,23 +446,29 @@ def _retry(res):
d.addCallback(_retry)
return d
@defer.inlineCallbacks
def _fullClone(self, shallowClone=False):
"""Perform full clone and checkout to the revision if specified
In the case of shallow clones if any of the step fail abort whole build step.
"""
d = self._clone(shallowClone)
res = yield self._clone(shallowClone)
if res != 0:
defer.returnValue(res)
return
# If revision specified checkout that revision
if self.revision:
d.addCallback(lambda _: self._dovccmd(['reset', '--hard',
self.revision, '--'],
shallowClone))
res = yield self._dovccmd(['reset', '--hard',
self.revision, '--'],
shallowClone)
# init and update submodules, recurisively. If there's not recursion
# it will not do it.
if self.submodules:
d.addCallback(lambda _: self._dovccmd(['submodule', 'update',
'--init', '--recursive'],
shallowClone))
return d
res = yield self._dovccmd(['submodule', 'update',
'--init', '--recursive'],
shallowClone)
defer.returnValue(res)
def _fullCloneOrFallback(self):
"""Wrapper for _fullClone(). In the case of failure, if clobberOnFailure
@@ -490,7 +490,7 @@ def test_mode_full_clobber(self):
command=['git', 'clone',
'http://github.com/buildbot/buildbot.git',
'.', '--progress'])
+ 1,
+ 0,
ExpectShell(workdir='wkdir',
command=['git', 'rev-parse', 'HEAD'])
+ ExpectShell.log('stdio',
@@ -501,6 +501,34 @@ def test_mode_full_clobber(self):
self.expectProperty('got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', 'Git')
return self.runStep()
def test_mode_full_clone_fails(self):
self.setupStep(
git.Git(repourl='http://github.com/buildbot/buildbot.git',
mode='full', method='clobber', progress=True))
self.expectCommands(
ExpectShell(workdir='wkdir',
command=['git', '--version'])
+ ExpectShell.log('stdio',
stdout='git version 1.7.5')
+ 0,
Expect('stat', dict(file='wkdir/.buildbot-patched',
logEnviron=True))
+ 1,
Expect('rmdir', dict(dir='wkdir',
logEnviron=True,
timeout=1200))
+ 0,
ExpectShell(workdir='wkdir',
command=['git', 'clone',
'http://github.com/buildbot/buildbot.git',
'.', '--progress'])
+ 1, # clone fails
)
self.expectOutcome(result=FAILURE, status_text=["updating"])
self.expectNoProperty('got_revision')
return self.runStep()
def test_mode_full_clobber_branch(self):
self.setupStep(
git.Git(repourl='http://github.com/buildbot/buildbot.git',

0 comments on commit 2979c5e

Please sign in to comment.