mirror of
https://github.com/ansible/ansible.git
synced 2026-06-09 08:56:17 -04:00
Merge 25fc632279 into ba21909655
This commit is contained in:
commit
9e52de47d3
2 changed files with 9 additions and 1 deletions
4
changelogs/fragments/shallow_git_clone.yml
Normal file
4
changelogs/fragments/shallow_git_clone.yml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
minor_changes:
|
||||
- ansible-galaxy - Perform shallow (depth=1) git clone when version is HEAD
|
||||
- ansible-galaxy - Don't perform unnecessary checkout when version is HEAD
|
||||
|
|
@ -63,6 +63,10 @@ def scm_archive_resource(src, scm='git', name=None, version='HEAD', keep_scm_met
|
|||
tempdir = tempfile.mkdtemp(dir=C.DEFAULT_LOCAL_TMP)
|
||||
clone_cmd = [scm_path, 'clone']
|
||||
|
||||
# Perform a shallow clone if simply cloning HEAD
|
||||
if scm == 'git' and version == 'HEAD':
|
||||
clone_cmd.append('--depth=1')
|
||||
|
||||
# Add specific options for ignoring certificates if requested
|
||||
ignore_certs = context.CLIARGS['ignore_certs'] or C.GALAXY_IGNORE_CERTS
|
||||
|
||||
|
|
@ -76,7 +80,7 @@ def scm_archive_resource(src, scm='git', name=None, version='HEAD', keep_scm_met
|
|||
|
||||
run_scm_cmd(clone_cmd, tempdir)
|
||||
|
||||
if scm == 'git' and version:
|
||||
if scm == 'git' and version and version != 'HEAD':
|
||||
checkout_cmd = [scm_path, 'checkout', to_text(version)]
|
||||
run_scm_cmd(checkout_cmd, os.path.join(tempdir, name))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue