class SuperHooks::Runner

Class responsible for running the hooks and reporting on status

Attributes

arguments[R]

arguments passed by git when running a hook

hooks[R]

the hooks one would like to run

Public Class Methods

new(hook, arguments) click to toggle source

Prepare for a new commit runner check

  • hook: the hook name wer're about to run

  • arguments: the arguments past to the hook

# File lib/super_hooks/runner.rb, line 15
def initialize(hook, arguments)
  @hooks = Hook.where(kind: [hook])
  @arguments = arguments
end

Public Instance Methods

run() click to toggle source

Run all the associated hooks

Exit the program with a bad status if any of the hooks fail

# File lib/super_hooks/runner.rb, line 24
def run
  failed_hooks = []
  hooks.each do |hook|
    failed_hooks << hook unless hook.execute!(arguments)
  end

  unless failed_hooks.empty?
    $stderr.puts "Hooks #{failed_hooks.map(&:path).join(', ')} failed to exit successfully"
    exit 1
  end
end