Method: Overcommit::Hook::Base#process_hook_return_value
- Defined in:
- lib/overcommit/hook/base.rb
#process_hook_return_value(hook_return_value) ⇒ Array<Symbol,String>
Converts the hook’s return value into a canonical form of a tuple containing status (pass/warn/fail) and output.
This is intended to support various shortcuts for writing hooks so that hook authors don’t need to work with Message objects for simple pass/fail hooks. It also saves you from needing to manually encode logic like “if there are errors, fail; if there are warnings, warn, otherwise pass.” by simply returning an array of Message objects.
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/overcommit/hook/base.rb', line 63 def process_hook_return_value(hook_return_value) if hook_return_value.is_a?(Array) && hook_return_value.first.is_a?(Message) # Process messages into a status and output Overcommit::MessageProcessor.new( self, @config['problem_on_unmodified_line'], ).hook_result(hook_return_value) else # Otherwise return as-is hook_return_value end end |