Skip to content

Commit

Permalink
buildslave/git: Don't fail the whole build if git branch -M can't ren…
Browse files Browse the repository at this point in the history
…ame master.

Previous versions of Git allowed the current branch to be renamed. For
some reason, Git 1.7.7 does not allow this. All attempts to rename the
current branch fail with "Cannot force update the current branch." So,
if the rename fails, don't abort.

As part of this, add support for commands that can fail.
  • Loading branch information
Charles Davis committed Oct 9, 2011
1 parent c135825 commit 38525c1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions slave/buildslave/commands/git.py
Expand Up @@ -63,7 +63,7 @@ def _fullSrcdir(self):
def sourcedirIsUpdateable(self):
return os.path.isdir(os.path.join(self._fullSrcdir(), ".git"))

def _dovccmd(self, command, cb=None, **kwargs):
def _dovccmd(self, command, cb=None, stopOnFail=True, **kwargs):
git = self.getCommand("git")
c = runprocess.RunProcess(self.builder, [git] + command, self._fullSrcdir(),
sendRC=False, timeout=self.timeout,
Expand All @@ -72,7 +72,8 @@ def _dovccmd(self, command, cb=None, **kwargs):
self.command = c
d = c.start()
if cb:
d.addCallback(self._abandonOnFailure)
if stopOnFail:
d.addCallback(self._abandonOnFailure)
d.addCallback(cb)
return d

Expand Down Expand Up @@ -107,7 +108,7 @@ def _didHeadCheckout(self, res):
# Rename branch, so that the repo will have the expected branch name
# For further information about this, see the commit message
command = ['branch', '-M', self.branch]
return self._dovccmd(command, self._initSubmodules)
return self._dovccmd(command, self._initSubmodules, False)

def _didFetch(self, res):
if self.revision:
Expand Down

0 comments on commit 38525c1

Please sign in to comment.