Skip to content

Commit

Permalink
Check git version for --branch support. Fixes #2504
Browse files Browse the repository at this point in the history
  • Loading branch information
srinupiits committed Aug 1, 2013
1 parent 97eff1c commit 6784f5f
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 11 deletions.
26 changes: 15 additions & 11 deletions master/buildbot/steps/source/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from twisted.python import log
from twisted.internet import defer, reactor
from distutils.version import StrictVersion

from buildbot import config as bbconfig
from buildbot.process import buildstep
Expand Down Expand Up @@ -118,6 +119,7 @@ def __init__(self, repourl=None, branch='HEAD', mode='incremental', method=None,
self.mode = mode
self.getDescription = getDescription
self.config = config
self.supportsBranch = True
Source.__init__(self, **kwargs)

if self.mode not in ['incremental', 'full']:
Expand All @@ -138,8 +140,7 @@ def startVC(self, branch, revision, patch):
self.method = self._getMethod()
self.stdio_log = self.addLogForRemoteCommands("stdio")


d = self.checkGit()
d = self.checkBranchSupport()
def checkInstall(gitInstalled):
if not gitInstalled:
raise BuildSlaveTooOldError("git is not installed on slave")
Expand Down Expand Up @@ -389,7 +390,7 @@ def _clone(self, shallowClone):
"""Retry if clone failed"""

args = []
if self.branch != 'HEAD':
if self.supportsBranch and self.branch != 'HEAD':
args += ['--branch', self.branch]
if shallowClone:
args += ['--depth', '1']
Expand Down Expand Up @@ -504,12 +505,15 @@ def _getMethod(self):
elif self.method is None and self.mode == 'full':
return 'fresh'

def checkGit(self):
d = self._dovccmd(['--version'])
def check(res):
if res == 0:
return True
return False

d.addCallback(check)
def checkBranchSupport(self):
d = self._dovccmd(['--version'], collectStdout=True)
def checkSupport(stdout):
gitInstalled = False
if 'git' in stdout:
gitInstalled = True
version = stdout.strip().split(' ')[2]
if StrictVersion(version) < StrictVersion("1.6.5"):
self.supportsBranch = False
return gitInstalled
d.addCallback(checkSupport)
return d

0 comments on commit 6784f5f

Please sign in to comment.