From 123c99f87915a38e12a22f5aeabb38537cb19709 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Mon, 15 Dec 2014 13:34:03 -0800 Subject: [PATCH] Add error message from git to message returned from ansible Fixes #81 --- lib/ansible/modules/source_control/git.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/ansible/modules/source_control/git.py b/lib/ansible/modules/source_control/git.py index 72f56a2fd8c..a2de91a15fe 100644 --- a/lib/ansible/modules/source_control/git.py +++ b/lib/ansible/modules/source_control/git.py @@ -455,19 +455,21 @@ def fetch(git_path, module, repo, dest, version, remote, bare): (rc, out1, err1) = module.run_command([git_path, 'fetch', remote, '+refs/heads/*:refs/heads/*'], cwd=dest) else: (rc, out1, err1) = module.run_command("%s fetch %s" % (git_path, remote), cwd=dest) - if rc != 0: - module.fail_json(msg="Failed to download remote objects and refs") out_acc.append(out1) err_acc.append(err1) + if rc != 0: + module.fail_json(msg="Failed to download remote objects and refs: %s %s" % + (''.join(out_acc), ''.join(err_acc))) if bare: (rc, out2, err2) = module.run_command([git_path, 'fetch', remote, '+refs/tags/*:refs/tags/*'], cwd=dest) else: (rc, out2, err2) = module.run_command("%s fetch --tags %s" % (git_path, remote), cwd=dest) - if rc != 0: - module.fail_json(msg="Failed to download remote objects and refs") out_acc.append(out2) err_acc.append(err2) + if rc != 0: + module.fail_json(msg="Failed to download remote objects and refs: %s %s" % + (''.join(out_acc), ''.join(err_acc))) return (rc, ''.join(out_acc), ''.join(err_acc))