Module: Overcommit::Hook::Shared::Pronto

Included in:
PreCommit::Pronto, PrePush::Pronto
Defined in:
lib/overcommit/hook/shared/pronto.rb

Overview

Shared code used by all Pronto hooks. Runs pronto linter.

Constant Summary collapse

MESSAGE_TYPE_CATEGORIZER =
lambda do |type|
  type.include?('E') ? :error : :warning
end

Instance Method Summary collapse

Instance Method Details

#runObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/overcommit/hook/shared/pronto.rb', line 10

def run
  result = execute(command)
  return :pass if result.success?

  extract_messages(
    result.stdout.split("\n"),
    /^(?<file>(?:\w:)?[^:]+):(?<line>\d+) (?<type>[^ ]+)/,
    MESSAGE_TYPE_CATEGORIZER,
  )
end