Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/ayust/buildbot
Browse files Browse the repository at this point in the history
* 'master' of git://github.com/ayust/buildbot:
  Add optional 'reference' parameter for Git VCS.
  Added optional 'progress' parameter for Git VCS.
  • Loading branch information
Dustin J. Mitchell committed Sep 28, 2010
2 parents 9d56bbf + dfb6cb8 commit da435c8
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
15 changes: 15 additions & 0 deletions master/buildbot/steps/source.py
Expand Up @@ -766,7 +766,9 @@ def __init__(self, repourl=None,
branch="master",
submodules=False,
ignore_ignores=None,
reference=None,
shallow=False,
progress=False,
**kwargs):
"""
@type repourl: string
Expand All @@ -781,21 +783,34 @@ def __init__(self, repourl=None,
@param submodules: Whether or not to update (and initialize)
git submodules.
@type reference: string
@param reference: The path to a reference repository to obtain
objects from, if any.
@type shallow: boolean
@param shallow: Use a shallow or clone, if possible
@type progress: boolean
@param progress: Pass the --progress option when fetching. This
can solve long fetches getting killed due to
lack of output, but requires Git 1.7.2+.
"""
Source.__init__(self, **kwargs)
self.repourl = repourl
self.addFactoryArguments(repourl=repourl,
branch=branch,
submodules=submodules,
ignore_ignores=ignore_ignores,
reference=reference,
shallow=shallow,
progress=progress,
)
self.args.update({'branch': branch,
'submodules': submodules,
'ignore_ignores': ignore_ignores,
'reference': reference,
'shallow': shallow,
'progress': progress,
})

def computeSourceRevision(self, changes):
Expand Down
10 changes: 10 additions & 0 deletions master/docs/cfg-buildsteps.texinfo
Expand Up @@ -867,10 +867,20 @@ branch will be used.
(optional): when initializing/updating a Git repository, this decides whether
or not buildbot should consider git submodules. Default: False.

@item reference
(optional): use the specified string as a path to a reference repository on the
local machine. Git will try to grab objects from this path first instead of the
main repository, if they exist.

@item shallow
(optional): instructs git to attempt shallow clones (@code{--depth 1}). If the
user/scheduler asks for a specific revision, this parameter is ignored.

@item progress
(optional): passes the (@code{--progress}) flag to (@code{git fetch}). This
solves issues of long fetches being killed due to lack of output, but requires
Git 1.7.2 or later.

@end table


Expand Down
22 changes: 20 additions & 2 deletions slave/buildslave/commands/git.py
Expand Up @@ -17,6 +17,7 @@ class Git(SourceBaseCommand):
['submodules'] (optional): whether to initialize and update
submodules. Default: False.
['ignore_ignores']: ignore ignores when purging changes.
['reference'] (optional): use this reference repository to fetch objects
"""

header = "git operation"
Expand All @@ -30,6 +31,7 @@ def setup(self, args):
self.sourcedata = "%s %s\n" % (self.repourl, self.branch)
self.submodules = args.get('submodules')
self.ignore_ignores = args.get('ignore_ignores', True)
self.reference = args.get('reference', None)

def _fullSrcdir(self):
return os.path.join(self.builder.basedir, self.srcdir)
Expand Down Expand Up @@ -121,6 +123,12 @@ def _doFetch(self, dummy):
# 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]
# If the 'progress' option is set, tell git fetch to output
# progress information to the log. This can solve issues with
# long fetches killed due to lack of output, but only works
# with Git 1.7.2 or later.
if self.args.get('progress'):
command.append('--progress')
self.sendStatus({"header": "fetching branch %s from %s\n"
% (self.branch, self.repourl)})
return self._dovccmd(command, self._didFetch)
Expand All @@ -140,6 +148,13 @@ def _didClean(self, dummy):
return self._doFetch(None)

def _didInit(self, res):
# If we have a reference repository specified, we need to also set that
# up after the 'git init'.
if self.reference:
git_alts_path = os.path.join(self._fullSrcdir(), '.git', 'objects', 'info', 'alternates')
git_alts_file = open(git_alts_path, 'w')
git_alts_file.write(self.reference)
git_alts_file.close()
return self.doVCUpdate()

def doVCFull(self):
Expand All @@ -148,8 +163,11 @@ def doVCFull(self):
# If they didn't ask for a specific revision, we can get away with a
# shallow clone.
if not self.args.get('revision') and self.args.get('shallow'):
cmd = [git, 'clone', '--depth', '1', self.repourl,
self._fullSrcdir()]
cmd = [git, 'clone', '--depth', '1']
# If we have a reference repository, pass it to the clone command
if self.reference:
cmd.extend(['--reference', self.reference])
cmd.extend([self.repourl, self._fullSrcdir()])
c = runprocess.RunProcess(self.builder, cmd, self.builder.basedir,
sendRC=False, timeout=self.timeout,
maxTime=self.maxTime, usePTY=False)
Expand Down

0 comments on commit da435c8

Please sign in to comment.