1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

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.
This commit is contained in:
Petr Svoboda 2013-08-01 11:59:06 +02:00
parent 8cc13590b4
commit 2d5b942ffe

View file

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