Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error handling when switching versions #790

Merged
merged 1 commit into from
Aug 8, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 2 additions & 7 deletions library/git
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ def reset(dest):
rc = cmd.returncode
return (rc, out, err)

def switchLocalBranch( branch ):
cmd = "git checkout %s" % branch
cmd = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
return cmd.communicate()

def get_branches(module, dest):
os.chdir(dest)
branches = []
Expand Down Expand Up @@ -156,7 +151,7 @@ def main():

gitconfig = os.path.join(dest, '.git', 'config')

out, err, status = (None, None, None)
rc, out, err, status = (0, None, None, None)

# if there is no git configuration, do a clone operation
# else pull and switch the version
Expand All @@ -180,7 +175,7 @@ def main():
# switch to version specified regardless of whether
# we cloned or pulled
(rc, out, err) = switch_version(module, dest, remote, version)
if err.find('error') != -1:
if rc != 0:
module.fail_json(msg=err)

# determine if we changed anything
Expand Down