Skip to content

Commit

Permalink
Add new parameter called 'update_submodules' for 'git submodule updat…
Browse files Browse the repository at this point in the history
…e' that does not fetch every submodule
  • Loading branch information
elmeriniemela committed Dec 8, 2019
1 parent 03a4edb commit 19aed86
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lib/ansible/modules/source_control/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,16 @@
default: []
version_added: "2.9"
update_submodules:
description:
- Run 'git submodule update' on the repository. This is done without
fetching every submodule to determine if it has changed, thus
combining this with recursive=False offers significant performance
boost compared to recursive=True when using submodules.
type: bool
default: 'no'
version_added: "2.10"
requirements:
- git>=1.7.1 (the command line tool)
Expand Down Expand Up @@ -1060,6 +1070,7 @@ def main():
umask=dict(default=None, type='raw'),
archive=dict(type='path'),
separate_git_dir=dict(type='path'),
update_submodules=dict(default='no', type='bool'),
),
mutually_exclusive=[('separate_git_dir', 'bare')],
supports_check_mode=True
Expand All @@ -1084,6 +1095,7 @@ def main():
umask = module.params['umask']
archive = module.params['archive']
separate_git_dir = module.params['separate_git_dir']
update_submodules = module.params['update_submodules']

result = dict(changed=False, warnings=list())

Expand Down Expand Up @@ -1240,8 +1252,9 @@ def main():
result.update(changed=True, after=remote_head)
module.exit_json(**result)

# Switch to version specified
submodule_update(git_path, module, dest, track_submodules, force=force)
if (submodules_updated or update_submodules) and not bare:
# Switch to version specified
submodule_update(git_path, module, dest, track_submodules, force=force)

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

0 comments on commit 19aed86

Please sign in to comment.