Merge pull request #1723 from sfromm/issue1722

Fix git module to update branch to latest when using version=<branch>
pull/1724/head
Stephen Fromm 12 years ago
commit 1d910bb4e3

@ -199,6 +199,12 @@ def switch_version(module, dest, remote, version):
if version != 'HEAD': if version != 'HEAD':
if not is_local_branch(module, dest, version) and is_remote_branch(module, dest, remote, version): if not is_local_branch(module, dest, version) and is_remote_branch(module, dest, remote, version):
cmd = "git checkout --track -b %s %s/%s" % (version, remote, version) cmd = "git checkout --track -b %s %s/%s" % (version, remote, version)
elif is_local_branch(module, dest, version):
cmd = "git checkout --force %s" % version
(rc, out, err) = _run("git checkout --force %s" % version)
if rc != 0:
module.fail_json(msg="Failed to checkout branch %s" % version)
cmd = "git reset --hard %s/%s" % (remote, version)
else: else:
cmd = "git checkout --force %s" % version cmd = "git checkout --force %s" % version
else: else:

Loading…
Cancel
Save