Class: Overcommit::Hook::PreCommit::ChamberVerification

Inherits:
Base
  • Object
show all
Defined in:
lib/overcommit/hook/pre_commit/chamber_verification.rb

Overview

Runs ‘chamber sign –verify`.

rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity

Instance Attribute Summary

Attributes inherited from Base

#config

Instance Method Summary collapse

Methods inherited from Base

#applicable_files, #command, #description, #enabled?, #execute, #execute_in_background, #flags, #in_path?, #included_files, #initialize, #name, #parallelize?, #processors, #quiet?, #required?, #required_executable, #required_libraries, #run?, #run_and_transform, #skip?

Constructor Details

This class inherits a constructor from Overcommit::Hook::Base

Instance Method Details

#runObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# 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