Merge pull request #3578 from jlaska/git_branch

(git module) Resolve incompatability between depth and version
reviewable/pr18780/r1
Michael DeHaan 11 years ago
commit 0bd375f83e

@ -99,7 +99,7 @@ def get_version(git_path, dest):
sha = sha[0].split()[1] sha = sha[0].split()[1]
return sha return sha
def clone(git_path, module, repo, dest, remote, depth): def clone(git_path, module, repo, dest, remote, depth, version):
''' makes a new git repo if it does not already exist ''' ''' makes a new git repo if it does not already exist '''
dest_dirname = os.path.dirname(dest) dest_dirname = os.path.dirname(dest)
try: try:
@ -108,6 +108,8 @@ def clone(git_path, module, repo, dest, remote, depth):
pass pass
os.chdir(dest_dirname) os.chdir(dest_dirname)
cmd = [ git_path, 'clone', '-o', remote, '--recursive' ] cmd = [ git_path, 'clone', '-o', remote, '--recursive' ]
if version:
cmd.extend([ '--branch', str(version) ])
if depth: if depth:
cmd.extend([ '--depth', str(depth) ]) cmd.extend([ '--depth', str(depth) ])
cmd.extend([ repo, dest ]) cmd.extend([ repo, dest ])
@ -317,7 +319,7 @@ def main():
if not os.path.exists(gitconfig): if not os.path.exists(gitconfig):
if module.check_mode: if module.check_mode:
module.exit_json(changed=True) module.exit_json(changed=True)
(rc, out, err) = clone(git_path, module, repo, dest, remote, depth) (rc, out, err) = clone(git_path, module, repo, dest, remote, depth, version)
elif not update: elif not update:
# Just return having found a repo already in the dest path # Just return having found a repo already in the dest path
# this does no checking that the repo is the actual repo # this does no checking that the repo is the actual repo

Loading…
Cancel
Save