Commit 051d8f09 authored by Julien Muchembled's avatar Julien Muchembled

gitclone: new 'depth' option

parent 03a41274
......@@ -848,6 +848,9 @@ option to 'true'::
Other options
~~~~~~~~~~~~~
depth
Clone with ``--depth=<depth>`` option. See ``git-clone`` command.
shared
Clone with ``--shared`` option if true. See ``git-clone`` command.
......
......@@ -534,6 +534,16 @@ repository = %s
# and running buildout again succeeed
check_call([buildout])
def test_clone_depth(self):
options = {}
self.makeGitCloneRecipe(options).install()
get_depth = lambda: int(check_output(('git', 'rev-list', '--count', '@'),
cwd=options['location']))
self.assertLess(100, get_depth())
options['depth'] = 10
self.makeGitCloneRecipe(options).install()
self.assertEqual(10, get_depth())
class MakeReadOnlyTests(unittest.TestCase):
......
......@@ -135,20 +135,16 @@ class Recipe(object):
os.path.join(buildout['buildout']['parts-directory'], name))
self.name = name
for option in ('branch', 'revision', 'location', 'repository'):
value = options.get(option, '').strip()
if value == '':
setattr(self, option, None)
else:
setattr(self, option, value)
self.git_command = options.get('git-executable', '')
if self.git_command == '':
self.git_command = 'git'
self.sparse = options.get('sparse-checkout', '').strip()
setattr(self, option, options.get(option) or None)
self.git_command = options.get('git-executable') or 'git'
self.sparse = options.get('sparse-checkout')
depth = options.get('depth')
self.depth = int(depth) if depth else None
# Set boolean values
for key in ('develop', 'shared', 'use-cache', 'ignore-ssl-certificate',
'ignore-cloning-submodules'):
setattr(self, key.replace('-', '_'), options.get(key, '').lower() in TRUE_VALUES)
if self.shared:
if self.shared or depth:
self.use_cache = False
self.networkcache = buildout.get('networkcache', {})
......@@ -210,6 +206,8 @@ class Recipe(object):
git_clone_command += '--branch', self.branch
if self.ignore_ssl_certificate:
config.append('http.sslVerify=false')
if self.depth is not None:
git_clone_command.append('--depth=%s' % self.depth)
if config and self.use_cache:
raise NotImplementedError
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment