From 2b003a2773aaecf57c9d0e37a798d0827c036c1f Mon Sep 17 00:00:00 2001 From: Kyle Dyroff Date: Tue, 19 Apr 2016 02:56:48 -0400 Subject: [PATCH] Log git error stdout/stderr to fail_json (#3022) --- source_control/git.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/source_control/git.py b/source_control/git.py index 546ad0b2991..1230b187477 100644 --- a/source_control/git.py +++ b/source_control/git.py @@ -650,7 +650,8 @@ def switch_version(git_path, module, dest, remote, version, verify_commit): else: (rc, out, err) = module.run_command("%s checkout --force %s" % (git_path, version), cwd=dest) if rc != 0: - module.fail_json(msg="Failed to checkout branch %s" % version) + module.fail_json(msg="Failed to checkout branch %s" % version, + stdout=out, stderr=err, rc=rc) cmd = "%s reset --hard %s/%s" % (git_path, remote, version) else: cmd = "%s checkout --force %s" % (git_path, version) @@ -658,14 +659,17 @@ def switch_version(git_path, module, dest, remote, version, verify_commit): branch = get_head_branch(git_path, module, dest, remote) (rc, out, err) = module.run_command("%s checkout --force %s" % (git_path, branch), cwd=dest) if rc != 0: - module.fail_json(msg="Failed to checkout branch %s" % branch) + module.fail_json(msg="Failed to checkout branch %s" % branch, + stdout=out, stderr=err, rc=rc) cmd = "%s reset --hard %s" % (git_path, remote) (rc, out1, err1) = module.run_command(cmd, cwd=dest) if rc != 0: if version != 'HEAD': - module.fail_json(msg="Failed to checkout %s" % (version), stdout=out1, stderr=err1) + module.fail_json(msg="Failed to checkout %s" % (version), + stdout=out1, stderr=err1, rc=rc, cmd=cmd) else: - module.fail_json(msg="Failed to checkout branch %s" % (branch)) + module.fail_json(msg="Failed to checkout branch %s" % (branch), + stdout=out1, stderr=err1, rc=rc, cmd=cmd) if verify_commit: verify_commit_sign(git_path, module, dest, version)