Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only update submodules when recursive is true #7033

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 7 additions & 4 deletions library/source_control/git
Expand Up @@ -429,7 +429,7 @@ def submodule_update(git_path, module, dest):
module.fail_json(msg="Failed to init/update submodules: %s" % out + err)
return (rc, out, err)

def switch_version(git_path, module, dest, remote, version):
def switch_version(git_path, module, dest, remote, version, recursive):
''' once pulled, switch to a particular SHA, tag, or branch '''
cmd = ''
if version != 'HEAD':
Expand All @@ -455,8 +455,11 @@ def switch_version(git_path, module, dest, remote, version):
module.fail_json(msg="Failed to checkout %s" % (version))
else:
module.fail_json(msg="Failed to checkout branch %s" % (branch))
(rc, out2, err2) = submodule_update(git_path, module, dest)
return (rc, out1 + out2, err1 + err2)
if recursive:
(rc, out2, err2) = submodule_update(git_path, module, dest)
out1 += out2
err1 += err1
return (rc, out1, err1)

# ===========================================

Expand Down Expand Up @@ -565,7 +568,7 @@ def main():
# switch to version specified regardless of whether
# we cloned or pulled
if not bare:
switch_version(git_path, module, dest, remote, version)
switch_version(git_path, module, dest, remote, version, recursive)

# determine if we changed anything
after = get_version(module, git_path, dest)
Expand Down