Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions pre_commit/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ def use_color(setting):
if setting not in COLOR_CHOICES:
raise InvalidColorSetting(setting)

if os.environ.get('NO_COLOR'):
return False

return (
setting == 'always' or
(setting == 'auto' and sys.stdout.isatty() and terminal_supports_color)
Expand Down
3 changes: 2 additions & 1 deletion pre_commit/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@

def _add_color_option(parser):
parser.add_argument(
'--color', default='auto', type=color.use_color,
'--color', default=os.environ.get('PRE_COMMIT_COLOR', 'auto'),
type=color.use_color,
metavar='{' + ','.join(color.COLOR_CHOICES) + '}',
help='Whether to use color in output. Defaults to `%(default)s`.',
)
Expand Down
16 changes: 0 additions & 16 deletions tests/color_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import unicode_literals

import os
import sys

import mock
Expand Down Expand Up @@ -51,18 +50,3 @@ def test_use_color_tty_without_color_support():
def test_use_color_raises_if_given_shenanigans():
with pytest.raises(InvalidColorSetting):
use_color('herpaderp')


def test_no_color_env_unset():
with mock.patch.dict(os.environ, clear=True):
assert use_color('always') is True


def test_no_color_env_empty():
with mock.patch.dict(os.environ, NO_COLOR=''):
assert use_color('always') is True


def test_no_color_env_non_empty():
with mock.patch.dict(os.environ, NO_COLOR=' '):
assert use_color('always') is False