Skip to content

Commit

Permalink
Merge pull request #1689 from jaredgrubb/git-inline-fetch-eight
Browse files Browse the repository at this point in the history
Git._fetch: move to defer.inlineCallbacks
  • Loading branch information
Mikhail Sobolev committed May 25, 2015
2 parents 8df4ed3 + 383eecf commit f4a7f59
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions master/buildbot/steps/source/git.py
Expand Up @@ -370,6 +370,7 @@ def evaluateCommand(cmd):
d.addCallback(lambda _: evaluateCommand(cmd))
return d

@defer.inlineCallbacks
def _fetch(self, _):
command = ['fetch', '-t', self.repourl, self.branch]
# If the 'progress' option is set, tell git fetch to output
Expand All @@ -379,29 +380,21 @@ def _fetch(self, _):
if self.prog:
command.append('--progress')

d = self._dovccmd(command)
yield self._dovccmd(command)

def checkout(_):
if self.revision:
rev = self.revision
else:
rev = 'FETCH_HEAD'
command = ['reset', '--hard', rev, '--']
abandonOnFailure = not self.retryFetch and not self.clobberOnFailure
return self._dovccmd(command, abandonOnFailure)
d.addCallback(checkout)
if self.revision:
rev = self.revision
else:
rev = 'FETCH_HEAD'
command = ['reset', '--hard', rev, '--']
abandonOnFailure = not self.retryFetch and not self.clobberOnFailure
res = yield self._dovccmd(command, abandonOnFailure)

def renameBranch(res):
if res != RC_SUCCESS:
return res
d = self._dovccmd(['branch', '-M', self.branch], abandonOnFailure=False)
if res == RC_SUCCESS and self.branch != 'HEAD':
# Ignore errors
d.addCallback(lambda _: res)
return d
yield self._dovccmd(['branch', '-M', self.branch], abandonOnFailure=False)

if self.branch != 'HEAD':
d.addCallback(renameBranch)
return d
defer.returnValue(res)

@defer.inlineCallbacks
def _fetchOrFallback(self, _=None):
Expand Down

0 comments on commit f4a7f59

Please sign in to comment.