Commit a3be9a52 authored by Alan Cutter's avatar Alan Cutter Committed by Commit Bot

Add --no-branch-color option to git cl status

Change-Id: Ieebdb32ac316a443789e26f3be8d5dcb4f94c4b6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1470404Reviewed-by: 's avatarEdward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Auto-Submit: Alan Cutter <alancutter@chromium.org>
parent 8f418985
...@@ -3948,6 +3948,10 @@ def CMDstatus(parser, args): ...@@ -3948,6 +3948,10 @@ def CMDstatus(parser, args):
Also see 'git cl comments'. Also see 'git cl comments'.
""" """
parser.add_option(
'--no-branch-color',
action='store_true',
help='Disable colorized branch names')
parser.add_option('--field', parser.add_option('--field',
help='print only specific field (desc|id|patch|status|url)') help='print only specific field (desc|id|patch|status|url)')
parser.add_option('-f', '--fast', action='store_true', parser.add_option('-f', '--fast', action='store_true',
...@@ -4019,14 +4023,6 @@ def CMDstatus(parser, args): ...@@ -4019,14 +4023,6 @@ def CMDstatus(parser, args):
return asterisk + color + branch_name + Fore.RESET return asterisk + color + branch_name + Fore.RESET
return asterisk + branch_name return asterisk + branch_name
def LeftPadColorfulString(string_plain, string_colorful, alignment):
"""Pad string_colorful with spaces until it hits alignment. Use string_plain
to compute required number of spaces."""
padding_amount = alignment - len(string_plain)
padding = ' ' * padding_amount
return padding + string_colorful
branch_statuses = {} branch_statuses = {}
alignment = max(5, max(len(FormatBranchName(c.GetBranch())) for c in changes)) alignment = max(5, max(len(FormatBranchName(c.GetBranch())) for c in changes))
...@@ -4048,14 +4044,13 @@ def CMDstatus(parser, args): ...@@ -4048,14 +4044,13 @@ def CMDstatus(parser, args):
reset = '' reset = ''
status_str = '(%s)' % status if status else '' status_str = '(%s)' % status if status else ''
branch_display_plain = FormatBranchName(branch) branch_display = FormatBranchName(branch)
branch_display_color = FormatBranchName(branch, colorize=True) padding = ' ' * (alignment - len(branch_display))
padded_branch_name = LeftPadColorfulString(branch_display_plain, if not options.no_branch_color:
branch_display_color, alignment) branch_display = FormatBranchName(branch, colorize=True)
print(' %s : %s%s %s%s' % (
padded_branch_name, color, url, status_str, reset))
print(' %s : %s%s %s%s' % (padding + branch_display, color, url,
status_str, reset))
print() print()
print('Current branch: %s' % current_branch) print('Current branch: %s' % current_branch)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment