File tree 2 files changed +22
-1
lines changed
2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,11 @@ def bold_warning(*args)
78
78
# @param partial [true,false] whether to omit a newline
79
79
def color ( code , str , partial = false )
80
80
send ( partial ? :partial : :log ,
81
- @out . tty? ? "\033 [#{ code } m#{ str } \033 [0m" : str )
81
+ colorize? ? "\033 [#{ code } m#{ str } \033 [0m" : str )
82
+ end
83
+
84
+ def colorize?
85
+ @out . tty? && ENV . fetch ( 'OVERCOMMIT_COLOR' , '1' ) != '0'
82
86
end
83
87
end
84
88
end
Original file line number Diff line number Diff line change 80
80
output . should_not include "\033 "
81
81
end
82
82
end
83
+
84
+ context 'when colorization is disabled' do
85
+ before do
86
+ io . stub ( :tty? ) . and_return ( true )
87
+ end
88
+
89
+ around do |example |
90
+ Overcommit ::Utils . with_environment 'OVERCOMMIT_COLOR' => '0' do
91
+ example . run
92
+ end
93
+ end
94
+
95
+ it 'omits the color escape sequence' do
96
+ subject
97
+ output . should_not include "\033 "
98
+ end
99
+ end
83
100
end
84
101
85
102
describe '#debug' do
You can’t perform that action at this time.
0 commit comments