Skip to content

Commit

Permalink
Git: make _sourcedirIsUpdatable a defer.inlineCallbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
Jared Grubb committed May 2, 2015
1 parent a431115 commit 15e919f
Showing 1 changed file with 24 additions and 27 deletions.
51 changes: 24 additions & 27 deletions master/buildbot/steps/source/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,34 +587,31 @@ def applyAlready(res):
return self._dovccmd(['apply', '--index', '-p', str(patch[0])], initialStdin=patch[1])
return d

@defer.inlineCallbacks
def _sourcedirIsUpdatable(self):
if self.slaveVersionIsOlderThan('listdir', '2.16'):
d = self.pathExists(self.build.path_module.join(self.workdir, '.git'))
git_path = self.build.path_module.join(self.workdir, '.git')
exists = yield self.pathExists(git_path)

@d.addCallback
def checkWithPathExists(exists):
if(exists):
return "update"
else:
return "clone"
else:
cmd = buildstep.RemoteCommand('listdir',
{'dir': self.workdir,
'logEnviron': self.logEnviron,
'timeout': self.timeout, })
cmd.useLog(self.stdio_log, False)
d = self.runCommand(cmd)
if exists:
defer.returnValue("update")

@d.addCallback
def checkWithListdir(_):
if 'files' not in cmd.updates:
# no files - directory doesn't exist
return "clone"
files = cmd.updates['files'][0]
if '.git' in files:
return "update"
elif len(files) > 0:
return "clobber"
else:
return "clone"
return d
defer.returnValue("clone")

cmd = buildstep.RemoteCommand('listdir',
{'dir': self.workdir,
'logEnviron': self.logEnviron,
'timeout': self.timeout, })
cmd.useLog(self.stdio_log, False)
yield self.runCommand(cmd)

if 'files' not in cmd.updates:
# no files - directory doesn't exist
defer.returnValue("clone")
files = cmd.updates['files'][0]
if '.git' in files:
defer.returnValue("update")
elif len(files) > 0:
defer.returnValue("clobber")
else:
defer.returnValue("clone")

0 comments on commit 15e919f

Please sign in to comment.