From c878ba60273c03a6fe7a6fa097f536aaa93e1c8a Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Mon, 3 Apr 2017 06:08:38 +0300 Subject: [PATCH] git map: Add -h option Bug: Change-Id: Ife7f4049062bc951e58d5c322b1fc7e39338fe79 Reviewed-on: https://chromium-review.googlesource.com/463246 Commit-Queue: anatoly techtonik Reviewed-by: Robbie Iannucci --- git_map.py | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/git_map.py b/git_map.py index 22e02e74b6..c765753a02 100755 --- a/git_map.py +++ b/git_map.py @@ -4,8 +4,9 @@ # found in the LICENSE file. """ -Provides an augmented `git log --graph` view. In particular, it also annotates -commits with branches + tags that point to them. Items are colorized as follows: +Enhances `git log --graph` view with information on commit branches + tags that +point to them. Items are colorized as follows: + * Cyan - Currently checked out branch * Green - Local branch * Red - Remote branches @@ -37,7 +38,33 @@ RESET = colorama.Fore.RESET + colorama.Back.RESET + colorama.Style.RESET_ALL # Git emits combined color BRIGHT_RED = '\x1b[1;31m' + +def print_help(): + names = { + 'Cyan': CYAN, + 'Green': GREEN, + 'Magenta': MAGENTA, + 'Red': RED, + 'White': WHITE, + 'Blue background': BLUEBAK, + } + msg = "usage: git map [-h] []\n" + + for line in __doc__.splitlines(): + for key in names.keys(): + if key in line: + msg += line.replace('* ', '* ' + names[key])+RESET+'\n' + break + else: + msg += line + '\n' + sys.stdout.write(msg) + + def main(argv): + if '-h' in argv: + print_help() + return 0 + map_extra = get_config_list('depot_tools.map_extra') fmt = '%C(red bold)%h%x09%Creset%C(green)%d%Creset %C(yellow)%ad%Creset ~ %s' log_proc = subprocess2.Popen(