From 82df6f981e6343f5cd9455d3374a02ea2855c5d4 Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Fri, 20 May 2016 18:45:53 +0200 Subject: [PATCH] Improve error reporting when git binary fail (#3266) Showing stderr or stdout is a great help to understand when something go south. --- lib/ansible/modules/source_control/git.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/ansible/modules/source_control/git.py b/lib/ansible/modules/source_control/git.py index 04ef7dda7fd..4830e8ea67b 100644 --- a/lib/ansible/modules/source_control/git.py +++ b/lib/ansible/modules/source_control/git.py @@ -296,7 +296,7 @@ def get_submodule_versions(git_path, module, dest, version='HEAD'): cmd = [git_path, 'submodule', 'foreach', git_path, 'rev-parse', version] (rc, out, err) = module.run_command(cmd, cwd=dest) if rc != 0: - module.fail_json(msg='Unable to determine hashes of submodules') + module.fail_json(msg='Unable to determine hashes of submodules', stdout=out, stderr=err, rc=rc) submodules = {} subm_name = None for line in out.splitlines(): @@ -400,7 +400,7 @@ def get_remote_head(git_path, module, dest, version, remote, bare): return version (rc, out, err) = module.run_command(cmd, check_rc=True, cwd=cwd) if len(out) < 1: - module.fail_json(msg="Could not determine remote revision for %s" % version) + module.fail_json(msg="Could not determine remote revision for %s" % version, stdout=out, stderr=err, rc=rc) if tag: # Find the dereferenced tag if this is an annotated tag. @@ -427,7 +427,7 @@ def get_branches(git_path, module, dest): cmd = '%s branch -a' % (git_path,) (rc, out, err) = module.run_command(cmd, cwd=dest) if rc != 0: - module.fail_json(msg="Could not determine branch data - received %s" % out) + module.fail_json(msg="Could not determine branch data - received %s" % out, stdout=out, stderr=err) for line in out.split('\n'): branches.append(line.strip()) return branches @@ -437,7 +437,7 @@ def get_tags(git_path, module, dest): cmd = '%s tag' % (git_path,) (rc, out, err) = module.run_command(cmd, cwd=dest) if rc != 0: - module.fail_json(msg="Could not determine tag data - received %s" % out) + module.fail_json(msg="Could not determine tag data - received %s" % out, stdout=out, stderr=err) for line in out.split('\n'): tags.append(line.strip()) return tags @@ -653,7 +653,7 @@ def set_remote_branch(git_path, module, dest, remote, version, depth): cmd = "%s fetch --depth=%s %s %s" % (git_path, depth, remote, branchref) (rc, out, err) = module.run_command(cmd, cwd=dest) if rc != 0: - module.fail_json(msg="Failed to fetch branch from remote: %s" % version) + module.fail_json(msg="Failed to fetch branch from remote: %s" % version, stdout=out, stderr=err, rc=rc) def switch_version(git_path, module, dest, remote, version, verify_commit): cmd = '' @@ -700,7 +700,7 @@ def verify_commit_sign(git_path, module, dest, version): cmd = "%s verify-commit %s" % (git_path, version) (rc, out, err) = module.run_command(cmd, cwd=dest) if rc != 0: - module.fail_json(msg='Failed to verify GPG signature of commit/tag "%s"' % version) + module.fail_json(msg='Failed to verify GPG signature of commit/tag "%s"' % version, stdout=out, stderr=err, rc=rc) return (rc, out, err) # ===========================================