Skip to content

Commit

Permalink
Fixing ticket buildbot#609
Browse files Browse the repository at this point in the history
The problem in the ticket is that Git does not checkout the wanted branch, but simply checks out master branch and resets it to the HEAD of the given branch. This means that any scripts in the build that rely on the name of the git-branch in the repo will not see the name they expect to see.

We do not want to simply checkout the branch every time, as that will leave a lot of "dangling" branches if the branch names are changed with time.
So, the decision is to do the same thing we did till now, but also add a step for renaming the branch to the expected name, and make sure the fetching will reset to the wanted revision.
  • Loading branch information
abyx committed Dec 31, 2009
1 parent a9fc66b commit 2e875ce
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions buildbot/slave/commands.py
Expand Up @@ -2207,6 +2207,12 @@ def _initSubmodules(self, res):
else:
return defer.succeed(0)

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)

def _didFetch(self, res):
if self.revision:
head = self.revision
Expand All @@ -2216,7 +2222,7 @@ def _didFetch(self, res):
# That is not sufficient. git will leave unversioned files and empty
# directories. Clean them up manually in _didReset.
command = ['reset', '--hard', head]
return self._dovccmd(command, self._initSubmodules)
return self._dovccmd(command, self._didHeadCheckout)

# Update first runs "git clean", removing local changes, This,
# combined with the later "git reset" equates clobbering the repo,
Expand All @@ -2228,7 +2234,9 @@ def doVCUpdate(self):
return self._dovccmd(command, self._didClean)

def _doFetch(self, dummy):
command = ['fetch', '-t', self.repourl, self.branch]
# The plus will make sure the repo is moved to the branch's
# head even if it is not a simple "fast-forward"
command = ['fetch', '-t', self.repourl, '+%s' % self.branch]
self.sendStatus({"header": "fetching branch %s from %s\n"
% (self.branch, self.repourl)})
return self._dovccmd(command, self._didFetch)
Expand Down

0 comments on commit 2e875ce

Please sign in to comment.