Skip to content

Commit

Permalink
rename repoDepth to just plain depth, and add a test for it
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Apr 17, 2014
1 parent a6dd226 commit 80f6744
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
12 changes: 6 additions & 6 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", "repoDepth"]
"repoDownloads", "depth"]

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,7 +116,7 @@ def __init__(self,
updateTarballAge=7 * 24.0 * 3600.0,
manifestOverrideUrl=None,
repoDownloads=None,
repoDepth=0,
depth=0,
**kwargs):
"""
@type manifestURL: string
Expand Down Expand Up @@ -144,8 +144,8 @@ 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.
@type depth: integer
@param depth: optional depth parameter to repo init.
If specified, create a shallow clone with given depth.
"""
self.manifestURL = manifestURL
Expand All @@ -159,7 +159,7 @@ def __init__(self,
if repoDownloads is None:
repoDownloads = []
self.repoDownloads = repoDownloads
self.repoDepth = repoDepth
self.depth = depth
Source.__init__(self, **kwargs)

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

if self.manifestOverrideUrl:
self.stdio_log.addHeader("overriding manifest with %s\n" % (self.manifestOverrideUrl))
Expand Down
12 changes: 10 additions & 2 deletions master/buildbot/test/unit/test_steps_source_repo.py
Expand Up @@ -120,14 +120,15 @@ def expectnoClobber(self):
+ 0,
)

def expectRepoSync(self, which_fail=-1, breakatfail=False, syncoptions=["-c"], override_commands=[]):
def expectRepoSync(self, which_fail=-1, breakatfail=False, depth=0,
syncoptions=["-c"], override_commands=[]):
commands = [
self.ExpectShell(
command=[
'bash', '-c', self.step._getCleanupCommand()]),
self.ExpectShell(
command=['repo', 'init', '-u', 'git://myrepo.com/manifest.git',
'-b', 'mb', '-m', 'mf', '--depth', '0'])
'-b', 'mb', '-m', 'mf', '--depth', str(depth)])
] + override_commands + [
self.ExpectShell(command=['repo', 'sync'] + syncoptions),
self.ExpectShell(
Expand All @@ -145,6 +146,13 @@ def test_basic(self):
self.expectRepoSync()
return self.myRunStep(status_text=["update"])

def test_basic_depth(self):
"""basic first time repo sync"""
self.mySetupStep(repoDownloads=None, depth=2)
self.expectClobber()
self.expectRepoSync(depth=2)
return self.myRunStep(status_text=["update"])

def test_update(self):
"""basic second time repo sync"""
self.mySetupStep()
Expand Down

0 comments on commit 80f6744

Please sign in to comment.