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

gitclone: new 'depth' option

parent 03a41274
...@@ -848,6 +848,9 @@ option to 'true':: ...@@ -848,6 +848,9 @@ option to 'true'::
Other options Other options
~~~~~~~~~~~~~ ~~~~~~~~~~~~~
depth
Clone with ``--depth=<depth>`` option. See ``git-clone`` command.
shared shared
Clone with ``--shared`` option if true. See ``git-clone`` command. Clone with ``--shared`` option if true. See ``git-clone`` command.
......
...@@ -534,6 +534,16 @@ repository = %s ...@@ -534,6 +534,16 @@ repository = %s
# and running buildout again succeeed # and running buildout again succeeed
check_call([buildout]) 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): class MakeReadOnlyTests(unittest.TestCase):
......
...@@ -135,20 +135,16 @@ class Recipe(object): ...@@ -135,20 +135,16 @@ class Recipe(object):
os.path.join(buildout['buildout']['parts-directory'], name)) os.path.join(buildout['buildout']['parts-directory'], name))
self.name = name self.name = name
for option in ('branch', 'revision', 'location', 'repository'): for option in ('branch', 'revision', 'location', 'repository'):
value = options.get(option, '').strip() setattr(self, option, options.get(option) or None)
if value == '': self.git_command = options.get('git-executable') or 'git'
setattr(self, option, None) self.sparse = options.get('sparse-checkout')
else: depth = options.get('depth')
setattr(self, option, value) self.depth = int(depth) if depth else None
self.git_command = options.get('git-executable', '')
if self.git_command == '':
self.git_command = 'git'
self.sparse = options.get('sparse-checkout', '').strip()
# Set boolean values # Set boolean values
for key in ('develop', 'shared', 'use-cache', 'ignore-ssl-certificate', for key in ('develop', 'shared', 'use-cache', 'ignore-ssl-certificate',
'ignore-cloning-submodules'): 'ignore-cloning-submodules'):
setattr(self, key.replace('-', '_'), options.get(key, '').lower() in TRUE_VALUES) setattr(self, key.replace('-', '_'), options.get(key, '').lower() in TRUE_VALUES)
if self.shared: if self.shared or depth:
self.use_cache = False self.use_cache = False
self.networkcache = buildout.get('networkcache', {}) self.networkcache = buildout.get('networkcache', {})
...@@ -210,6 +206,8 @@ class Recipe(object): ...@@ -210,6 +206,8 @@ class Recipe(object):
git_clone_command += '--branch', self.branch git_clone_command += '--branch', self.branch
if self.ignore_ssl_certificate: if self.ignore_ssl_certificate:
config.append('http.sslVerify=false') 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: if config and self.use_cache:
raise NotImplementedError 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