From 4208f1546c92f069e432d1865269ce539db8cea7 Mon Sep 17 00:00:00 2001 From: Ross Burton Date: Wed, 17 Jan 2018 17:11:33 +0000 Subject: buildhistory-diff: add support for colourising the output Colour value removes in red and additions in green, making it easier to scan the output for relevant changes. This adds a --colour option to specify whether colouring should be on, off, or detected. The default is detected, and depends on whether stdout is a TTY (same behaviour as git). Signed-off-by: Ross Burton Signed-off-by: Richard Purdie --- scripts/buildhistory-diff | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/buildhistory-diff b/scripts/buildhistory-diff index e79cb7ac8d..27974072fc 100755 --- a/scripts/buildhistory-diff +++ b/scripts/buildhistory-diff @@ -53,6 +53,10 @@ def get_args_parser(): parser.add_argument('-e', '--exclude-path', action='append', help="Exclude path from the output") + parser.add_argument('-c', '--colour', + choices=('yes', 'no', 'auto'), + default="auto", + help="Whether to colourise (defaults to auto)") parser.add_argument('revisions', default = ['build-minus-1', 'HEAD'], nargs='*', @@ -107,10 +111,11 @@ def main(): elif len(args.revisions) == 2: fromrev, torev = args.revisions - from oe.buildhistory_analysis import process_changes - + from oe.buildhistory_analysis import init_colours, process_changes import gitdb + init_colours({"yes": True, "no": False, "auto": sys.stdout.isatty()}[args.colour]) + try: changes = process_changes(args.buildhistory_dir, fromrev, torev, args.report_all, args.report_ver, args.sigs, -- cgit 1.2.3-korg