Fix coloring madness in depot_tools.
'setup_color' now contains logic to correctly detect:
* cmd
* cmd pipe
* msys bash
* msys pipe
* cmd running inside msys bash (git-command)
* cmd pipe running inside msys bash (git-command > outfile)
R=brucedawson@chromium.org, dnj@chromium.org
BUG=600049
Review URL: https://codereview.chromium.org/1851283002
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@299682 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/git_cl.py b/git_cl.py
index 4c6bb10..49891fc 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -45,6 +45,7 @@
import clang_format
import commit_queue
import dart_format
+import setup_color
import fix_encoding
import gclient_utils
import gerrit_util
@@ -2481,7 +2482,7 @@
issue_url, status = branch_statuses.pop(branch)
color = color_for_status(status)
reset = Fore.RESET
- if not sys.stdout.isatty():
+ if not setup_color.IS_TTY:
color = ''
reset = ''
status_str = '(%s)' % status if status else ''
@@ -4181,7 +4182,7 @@
group.add_option(
"--print-master", action='store_true', help="print master name as well.")
group.add_option(
- "--color", action='store_true', default=sys.stdout.isatty(),
+ "--color", action='store_true', default=setup_color.IS_TTY,
help="force color output, useful when piping output.")
group.add_option(
"--buildbucket-host", default='cr-buildbucket.appspot.com',
@@ -4615,7 +4616,7 @@
# These affect sys.stdout so do it outside of main() to simplify mocks in
# unit testing.
fix_encoding.fix_encoding()
- colorama.init(wrap="TERM" not in os.environ)
+ setup_color.init()
try:
sys.exit(main(sys.argv[1:]))
except KeyboardInterrupt: