Skip to content

Commit

Permalink
Support for --depth flag to repo init.
Browse files Browse the repository at this point in the history
This allows checking out a shallow clone with reduced history.
  • Loading branch information
rjogrady committed Apr 14, 2014
1 parent d3364bf commit b1b07eb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions master/buildbot/steps/source/repo.py
Expand Up @@ -94,7 +94,7 @@ class Repo(Source):
name = 'repo'
renderables = ["manifestURL", "manifestBranch", "manifestFile", "tarball", "jobs",
"syncAllBranches", "updateTarballAge", "manifestOverrideUrl",
"repoDownloads"]
"repoDownloads", "repoDepth"]

ref_not_found_re = re.compile(r"fatal: Couldn't find remote ref")
cherry_pick_error_re = re.compile(r"|".join([r"Automatic cherry-pick failed",
Expand All @@ -116,6 +116,7 @@ def __init__(self,
updateTarballAge=7 * 24.0 * 3600.0,
manifestOverrideUrl=None,
repoDownloads=None,
repoDepth=0,
**kwargs):
"""
@type manifestURL: string
Expand Down Expand Up @@ -143,6 +144,9 @@ def __init__(self,
@type repoDownloads: list of strings
@param repoDownloads: optional repo download to perform after the repo sync
@type repoDepth: integer
@param repoDepth: optional depth parameter to repo init.
If specified, create a shallow clone with given depth.
"""
self.manifestURL = manifestURL
self.manifestBranch = manifestBranch
Expand All @@ -155,6 +159,7 @@ def __init__(self,
if repoDownloads is None:
repoDownloads = []
self.repoDownloads = repoDownloads
self.repoDepth = repoDepth
Source.__init__(self, **kwargs)

assert self.manifestURL is not None
Expand Down Expand Up @@ -273,7 +278,8 @@ def doRepoSync(self, forceClobber=False):
yield self._repoCmd(['init',
'-u', self.manifestURL,
'-b', self.manifestBranch,
'-m', self.manifestFile])
'-m', self.manifestFile,
'--depth', str(self.repoDepth)])

if self.manifestOverrideUrl:
self.stdio_log.addHeader("overriding manifest with %s\n" % (self.manifestOverrideUrl))
Expand Down
4 changes: 2 additions & 2 deletions master/buildbot/test/unit/test_steps_source_repo.py
Expand Up @@ -127,7 +127,7 @@ def expectRepoSync(self, which_fail=-1, breakatfail=False, syncoptions=["-c"], o
'bash', '-c', self.step._getCleanupCommand()]),
self.ExpectShell(
command=['repo', 'init', '-u', 'git://myrepo.com/manifest.git',
'-b', 'mb', '-m', 'mf'])
'-b', 'mb', '-m', 'mf', '--depth', '0'])
] + override_commands + [
self.ExpectShell(command=['repo', 'sync'] + syncoptions),
self.ExpectShell(
Expand Down Expand Up @@ -395,7 +395,7 @@ def test_repo_download_manifest(self):
+ 0,
self.ExpectShell(
command=['repo', 'init', '-u', 'git://myrepo.com/manifest.git',
'-b', 'mb', '-m', 'mf'])
'-b', 'mb', '-m', 'mf', '--depth', '0'])
+ 0,
self.ExpectShell(
workdir='wkdir/.repo/manifests',
Expand Down

0 comments on commit b1b07eb

Please sign in to comment.