@@ -8,7 +8,8 @@ module Overcommit
8
8
class Printer
9
9
attr_reader :log
10
10
11
- def initialize ( logger , context )
11
+ def initialize ( config , logger , context )
12
+ @config = config
12
13
@log = logger
13
14
@context = context
14
15
@lock = Monitor . new # Need to use monitor so we can have re-entrant locks
@@ -17,7 +18,7 @@ def initialize(logger, context)
17
18
18
19
# Executed at the very beginning of running the collection of hooks.
19
20
def start_run
20
- log . bold "Running #{ hook_script_name } hooks"
21
+ log . bold "Running #{ hook_script_name } hooks" unless @config [ 'quiet' ]
21
22
end
22
23
23
24
def nothing_to_run
@@ -36,7 +37,7 @@ def required_hook_not_skipped(hook)
36
37
def end_hook ( hook , status , output )
37
38
# Want to print the header for quiet hooks only if the result wasn't good
38
39
# so that the user knows what failed
39
- print_header ( hook ) if !hook . quiet? || status != :pass
40
+ print_header ( hook ) if ( !hook . quiet? && ! @config [ 'quiet' ] ) || status != :pass
40
41
41
42
print_result ( hook , status , output )
42
43
end
@@ -69,9 +70,11 @@ def run_warned
69
70
70
71
# Executed when no hooks failed by the end of the run.
71
72
def run_succeeded
72
- log . newline
73
- log . success "✓ All #{ hook_script_name } hooks passed"
74
- log . newline
73
+ unless @config [ 'quiet' ]
74
+ log . newline
75
+ log . success "✓ All #{ hook_script_name } hooks passed"
76
+ log . newline
77
+ end
75
78
end
76
79
77
80
private
@@ -83,10 +86,10 @@ def print_header(hook)
83
86
log . partial hook_name
84
87
end
85
88
86
- def print_result ( hook , status , output )
89
+ def print_result ( hook , status , output ) # rubocop:disable Metrics/CyclomaticComplexity
87
90
case status
88
91
when :pass
89
- log . success 'OK' unless hook . quiet?
92
+ log . success 'OK' unless @config [ 'quiet' ] || hook . quiet?
90
93
when :warn
91
94
log . warning 'WARNING'
92
95
print_report ( output , :bold_warning )
0 commit comments