class Overcommit::Hook::PreCommit::ChamberVerification

Runs `chamber sign –verify`.

@see github.com/thekompanee/chamber/wiki/Git-Commit-Hooks#chamber-verification-pre-commit-hook rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity

Public Instance Methods

run() click to toggle source
# File lib/overcommit/hook/pre_commit/chamber_verification.rb, line 9
def run
  approver_name  = config.fetch('approver_name') { 'your approver' }
  approver_email = config['approver_email'] ? " (#{config['approver_email']})" : nil

  result = execute(command)

  return :pass if result.stdout.empty? && result.stderr.empty?
  return :pass if result.stderr =~ /no signature key was found/

  output = [
    result.stdout.empty? ? nil : result.stdout,
    result.stderr.empty? ? nil : result.stderr,
  ].
    compact.
    join("\n\n")

  output = "\n\n#{output}" unless output.empty?

  [
    :warn,
    "One or more of your settings files does not match the signature.\n" \
    "Talk to #{approver_name}#{approver_email} about getting them " \
    "approved.#{output}",
  ]
end