diff options
author | Robin Roth <robin.roth@kit.edu> | 2016-04-19 13:16:52 +0200 |
---|---|---|
committer | Robin Roth <robin.roth@kit.edu> | 2016-04-19 13:45:43 +0200 |
commit | b67d15f3855eaeccfe61bdab448c90cb28d0941d (patch) | |
tree | 5d83345d16cfbd30c228d9f5152cfd2e9e254c20 /source_control/git.py | |
parent | 766671f1e1ee0a293c360ffc803f1c65da8ac20a (diff) | |
download | ansible-modules-core-b67d15f3855eaeccfe61bdab448c90cb28d0941d.tar.gz |
fall back to full clone if version is hash
if version is not a branch or tag (i.e. a hash), we need a full checkout to be able to switch to it
Diffstat (limited to 'source_control/git.py')
-rw-r--r-- | source_control/git.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/source_control/git.py b/source_control/git.py index 1230b187..782bd1cb 100644 --- a/source_control/git.py +++ b/source_control/git.py @@ -321,14 +321,18 @@ def clone(git_path, module, repo, dest, remote, depth, version, bare, except: pass cmd = [ git_path, 'clone' ] + + branch_or_tag = is_remote_branch(git_path, module, dest, repo, version) \ + or is_remote_tag(git_path, module, dest, repo, version) + if bare: cmd.append('--bare') else: cmd.extend([ '--origin', remote ]) - if is_remote_branch(git_path, module, dest, repo, version) \ - or is_remote_tag(git_path, module, dest, repo, version): + if branch_or_tag: cmd.extend([ '--branch', version ]) - if depth: + if depth and (branch_or_tag or version == 'HEAD' or refspec): + # only use depth if the remote opject is branch or tag (i.e. fetchable) cmd.extend([ '--depth', str(depth) ]) if reference: cmd.extend([ '--reference', str(reference) ]) @@ -532,8 +536,9 @@ def fetch(git_path, module, repo, dest, version, remote, depth, bare, refspec): fetch_cmd.extend(['--depth', str(depth)]) fetch_cmd.extend([remote]) - if not depth: + if not depth or not refspecs: # don't try to be minimalistic but do a full clone + # also do this if depth is given, but version is something that can't be fetched directly if bare: refspecs = ['+refs/heads/*:refs/heads/*', '+refs/tags/*:refs/tags/*'] else: |