[libcamera-devel] [PATCH] utils: checkstyle.py: Fix color bleed

Tomi Valkeinen tomi.valkeinen at ideasonboard.com
Mon May 30 09:22:28 CEST 2022


If issue.line is None, the the terminal color is never reset back to
normal. This causes the yellow color to bleed.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen at ideasonboard.com>
---
 utils/checkstyle.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/utils/checkstyle.py b/utils/checkstyle.py
index 835f2a9f..fa0513f2 100755
--- a/utils/checkstyle.py
+++ b/utils/checkstyle.py
@@ -743,9 +743,9 @@ def check_file(top_level, commit, filename):
     if len(issues):
         issues = sorted(issues, key=lambda i: i.line_number)
         for issue in issues:
-            print('%s#%u: %s' % (Colours.fg(Colours.Yellow), issue.line_number, issue.msg))
+            print('%s#%u: %s%s' % (Colours.fg(Colours.Yellow), issue.line_number, issue.msg, Colours.reset()))
             if issue.line is not None:
-                print('+%s%s' % (issue.line.rstrip(), Colours.reset()))
+                print('%s+%s%s' % (Colours.fg(Colours.Yellow), issue.line.rstrip(), Colours.reset()))
 
     return len(formatted_diff) + len(issues)
 
-- 
2.34.1



More information about the libcamera-devel mailing list