|
|
@ -337,7 +337,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, version)
|
|
|
|
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
|
|
|
@ -351,9 +351,7 @@ def main():
|
|
|
|
# if force, do a reset
|
|
|
|
# if force, do a reset
|
|
|
|
if local_mods and module.check_mode:
|
|
|
|
if local_mods and module.check_mode:
|
|
|
|
module.exit_json(changed=True, msg='Local modifications exist')
|
|
|
|
module.exit_json(changed=True, msg='Local modifications exist')
|
|
|
|
(rc, out, err) = reset(git_path, module, dest, force)
|
|
|
|
reset(git_path, module, dest, force)
|
|
|
|
if rc != 0:
|
|
|
|
|
|
|
|
module.fail_json(msg=err)
|
|
|
|
|
|
|
|
# exit if already at desired sha version
|
|
|
|
# exit if already at desired sha version
|
|
|
|
if before == version:
|
|
|
|
if before == version:
|
|
|
|
module.exit_json(changed=False)
|
|
|
|
module.exit_json(changed=False)
|
|
|
@ -375,15 +373,11 @@ def main():
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
changed = False
|
|
|
|
changed = False
|
|
|
|
module.exit_json(changed=changed, before=before, after=remote_head)
|
|
|
|
module.exit_json(changed=changed, before=before, after=remote_head)
|
|
|
|
(rc, out, err) = fetch(git_path, module, repo, dest, version, remote)
|
|
|
|
fetch(git_path, module, repo, dest, version, remote)
|
|
|
|
if rc != 0:
|
|
|
|
|
|
|
|
module.fail_json(msg=err)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# switch to version specified regardless of whether
|
|
|
|
# switch to version specified regardless of whether
|
|
|
|
# we cloned or pulled
|
|
|
|
# we cloned or pulled
|
|
|
|
(rc, out, err) = switch_version(git_path, module, dest, remote, version)
|
|
|
|
switch_version(git_path, module, dest, remote, version)
|
|
|
|
if rc != 0:
|
|
|
|
|
|
|
|
module.fail_json(msg=err)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# determine if we changed anything
|
|
|
|
# determine if we changed anything
|
|
|
|
after = get_version(git_path, dest)
|
|
|
|
after = get_version(git_path, dest)
|
|
|
|