Fix traceback in git module when version checkout fails

"UnboundLocalError: local variable 'branch' referenced before assignment" is
raised in git, line 282, in switch_version.

Exception is raised when version is not branch and version checkout fails.
E.g. when version is nonexistant commit.
pull/3723/head
Petr Svoboda 11 years ago
parent 8cc13590b4
commit 2d5b942ffe

@ -271,6 +271,7 @@ def switch_version(git_path, module, dest, remote, version):
cmd = "%s reset --hard %s/%s" % (git_path, remote, version) cmd = "%s reset --hard %s/%s" % (git_path, remote, version)
else: else:
cmd = "%s checkout --force %s" % (git_path, version) cmd = "%s checkout --force %s" % (git_path, version)
branch = version
else: else:
branch = get_head_branch(git_path, module, dest, remote) branch = get_head_branch(git_path, module, dest, remote)
(rc, out, err) = module.run_command("%s checkout --force %s" % (git_path, branch)) (rc, out, err) = module.run_command("%s checkout --force %s" % (git_path, branch))

Loading…
Cancel
Save