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).

(From OE-Core rev: 4208f1546c92f069e432d1865269ce539db8cea7)

Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Ross Burton
2018-01-17 17:11:33 +00:00
committed by Richard Purdie
parent c1058ac4f2
commit 1c88db7a1c
2 changed files with 32 additions and 7 deletions

View File

@@ -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,