This commit is contained in:
betrotle 2026-05-27 22:06:39 -05:00 committed by GitHub
commit 9e52de47d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View 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

View file

@ -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))