Commit 0f601ebf authored by Julien Muchembled's avatar Julien Muchembled

gitclone: new 'sparse-checkout' option

parent 1b26856b
......@@ -138,6 +138,7 @@ class Recipe(object):
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
for key in ('develop', 'use-cache', 'ignore-ssl-certificate'):
setattr(self, key.replace('-', '_'), options.get(key, '').lower() in TRUE_VALUES)
......@@ -192,17 +193,30 @@ class Recipe(object):
git_clone_command = [self.git_command, 'clone',
self.repository,
self.location]
config = []
if self.sparse:
git_clone_command.append('--no-checkout')
config.append('core.sparseCheckout=true')
if self.branch:
git_clone_command.extend(['--branch', self.branch])
git_clone_command += '--branch', self.branch
if self.ignore_ssl_certificate:
git_clone_command.extend(['--config', 'http.sslVerify=false'])
config.append('http.sslVerify=false')
if config and self.use_cache:
raise NotImplementedError
for config in config:
git_clone_command += '--config', config
try:
check_call(git_clone_command, stdout=sys.stdout, stderr=sys.stdout)
if not os.path.exists(self.location):
raise UserError("Unknown error while cloning repository.")
if self.revision:
if self.sparse:
with open(os.path.join(self.location, '.git',
'info', 'sparse-checkout'), 'w') as f:
f.write(self.sparse + '\n')
self.gitReset(self.revision)
elif self.revision:
self.gitReset(self.revision)
if self.use_cache:
upload_network_cached(os.path.join(self.location, '.git'),
......
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