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

gitclone: new 'sparse-checkout' option

parent 1b26856b
Pipeline #2865 skipped
...@@ -138,6 +138,7 @@ class Recipe(object): ...@@ -138,6 +138,7 @@ class Recipe(object):
self.git_command = options.get('git-executable', '') self.git_command = options.get('git-executable', '')
if self.git_command == '': if self.git_command == '':
self.git_command = 'git' self.git_command = 'git'
self.sparse = options.get('sparse-checkout', '').strip()
# Set boolean values # Set boolean values
for key in ('develop', 'use-cache', 'ignore-ssl-certificate'): for key in ('develop', 'use-cache', 'ignore-ssl-certificate'):
setattr(self, key.replace('-', '_'), options.get(key, '').lower() in TRUE_VALUES) setattr(self, key.replace('-', '_'), options.get(key, '').lower() in TRUE_VALUES)
...@@ -192,17 +193,30 @@ class Recipe(object): ...@@ -192,17 +193,30 @@ class Recipe(object):
git_clone_command = [self.git_command, 'clone', git_clone_command = [self.git_command, 'clone',
self.repository, self.repository,
self.location] self.location]
config = []
if self.sparse:
git_clone_command.append('--no-checkout')
config.append('core.sparseCheckout=true')
if self.branch: if self.branch:
git_clone_command.extend(['--branch', self.branch]) git_clone_command += '--branch', self.branch
if self.ignore_ssl_certificate: 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: try:
check_call(git_clone_command, stdout=sys.stdout, stderr=sys.stdout) check_call(git_clone_command, stdout=sys.stdout, stderr=sys.stdout)
if not os.path.exists(self.location): if not os.path.exists(self.location):
raise UserError("Unknown error while cloning repository.") 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) self.gitReset(self.revision)
if self.use_cache: if self.use_cache:
upload_network_cached(os.path.join(self.location, '.git'), 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