Merge branch 'intellectronica/non-recursive-git' of git://github.com/intellectronica/ansible into devel
Conflicts: library/source_control/git
This commit is contained in:
commit
12391a4ba9
1 changed files with 19 additions and 3 deletions
|
@ -119,6 +119,15 @@ options:
|
||||||
description:
|
description:
|
||||||
- if C(yes), repository will be created as a bare repo, otherwise
|
- if C(yes), repository will be created as a bare repo, otherwise
|
||||||
it will be a standard repo with a workspace.
|
it will be a standard repo with a workspace.
|
||||||
|
|
||||||
|
recursive:
|
||||||
|
required: false
|
||||||
|
default: "yes"
|
||||||
|
choices: [ "yes", "no" ]
|
||||||
|
version_added: "1.6"
|
||||||
|
description:
|
||||||
|
- if C(no), repository will be cloned without the --recursive
|
||||||
|
option, skipping sub-modules.
|
||||||
notes:
|
notes:
|
||||||
- "If the task seems to be hanging, first verify remote host is in C(known_hosts).
|
- "If the task seems to be hanging, first verify remote host is in C(known_hosts).
|
||||||
SSH will prompt user to authorize the first contact with a remote host. To avoid this prompt,
|
SSH will prompt user to authorize the first contact with a remote host. To avoid this prompt,
|
||||||
|
@ -191,7 +200,8 @@ def get_version(module, git_path, dest, ref="HEAD"):
|
||||||
sha = stdout.rstrip('\n')
|
sha = stdout.rstrip('\n')
|
||||||
return sha
|
return sha
|
||||||
|
|
||||||
def clone(git_path, module, repo, dest, remote, depth, version, bare, reference):
|
def clone(git_path, module, repo, dest, remote, depth, version, bare,
|
||||||
|
reference, recursive):
|
||||||
''' 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:
|
||||||
|
@ -202,7 +212,9 @@ def clone(git_path, module, repo, dest, remote, depth, version, bare, reference)
|
||||||
if bare:
|
if bare:
|
||||||
cmd.append('--bare')
|
cmd.append('--bare')
|
||||||
else:
|
else:
|
||||||
cmd.extend([ '--origin', remote, '--recursive' ])
|
cmd.extend([ '--origin', remote ])
|
||||||
|
if recursive:
|
||||||
|
cmd.extend([ '--recursive' ])
|
||||||
if is_remote_branch(git_path, module, dest, repo, version) \
|
if is_remote_branch(git_path, module, dest, repo, version) \
|
||||||
or is_remote_tag(git_path, module, dest, repo, version):
|
or is_remote_tag(git_path, module, dest, repo, version):
|
||||||
cmd.extend([ '--branch', version ])
|
cmd.extend([ '--branch', version ])
|
||||||
|
@ -429,6 +441,7 @@ def main():
|
||||||
ssh_opts=dict(default=None, required=False),
|
ssh_opts=dict(default=None, required=False),
|
||||||
executable=dict(default=None),
|
executable=dict(default=None),
|
||||||
bare=dict(default='no', type='bool'),
|
bare=dict(default='no', type='bool'),
|
||||||
|
recursive=dict(default='yes', type='bool'),
|
||||||
),
|
),
|
||||||
supports_check_mode=True
|
supports_check_mode=True
|
||||||
)
|
)
|
||||||
|
@ -462,6 +475,8 @@ def main():
|
||||||
else:
|
else:
|
||||||
add_git_host_key(module, repo, accept_hostkey=module.params['accept_hostkey'])
|
add_git_host_key(module, repo, accept_hostkey=module.params['accept_hostkey'])
|
||||||
|
|
||||||
|
recursive = module.params['recursive']
|
||||||
|
|
||||||
if bare:
|
if bare:
|
||||||
gitconfig = os.path.join(dest, 'config')
|
gitconfig = os.path.join(dest, 'config')
|
||||||
else:
|
else:
|
||||||
|
@ -477,7 +492,8 @@ def main():
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
remote_head = get_remote_head(git_path, module, dest, version, repo, bare)
|
remote_head = get_remote_head(git_path, module, dest, version, repo, bare)
|
||||||
module.exit_json(changed=True, before=before, after=remote_head)
|
module.exit_json(changed=True, before=before, after=remote_head)
|
||||||
clone(git_path, module, repo, dest, remote, depth, version, bare, reference)
|
clone(git_path, module, repo, dest, remote, depth, version, bare,
|
||||||
|
reference, recursive)
|
||||||
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…
Reference in a new issue