From b1ec6e8163256ed09a45b1aadc0fbc8f2f065ffb Mon Sep 17 00:00:00 2001 From: Stephen Fromm Date: Tue, 4 Dec 2012 11:40:48 -0800 Subject: [PATCH] Fix git module to update branch to latest when using version= The git module would not pull in updates to a branch when version=. This updates that block to checkout the branch and then do a git reset --hard /. This should now track updates to a branch. --- library/git | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/library/git b/library/git index dd4a968f9fe..b73d5cace29 100644 --- a/library/git +++ b/library/git @@ -199,6 +199,12 @@ def switch_version(module, dest, remote, version): if version != 'HEAD': 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) + 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: cmd = "git checkout --force %s" % version else: