From dc71f28642b10afb1bab14e36e12461aadb3390c Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Thu, 16 Jun 2016 19:17:05 +0200 Subject: [PATCH] Handle color on multiple line in a cleaner way When using ansible deployment on git push, git insert "remote:" at the start of ansible output. If you force the color on ansible, the "remote:" also get colored if the string to display is on more than 1 line. This change make sure that each end of line reset the color, instead of reseting only at the end of the string. --- lib/ansible/utils/color.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/utils/color.py b/lib/ansible/utils/color.py index bc072c2fbb2..1c1c0468015 100644 --- a/lib/ansible/utils/color.py +++ b/lib/ansible/utils/color.py @@ -70,7 +70,7 @@ def stringc(text, color): """String in color.""" if ANSIBLE_COLOR: - return u"\033[%sm%s\033[0m" % (codeCodes[color], text) + return "\n".join([u"\033[%sm%s\033[0m" % (codeCodes[color], t) for t in text.split('\n')]) else: return text