class Overcommit::Hook::PreCommit::BerksfileCheck

Check if local Berksfile.lock matches Berksfile when either changes, unless Berksfile.lock is ignored by git.

@see berkshelf.com/

Constants

LOCK_FILE

Public Instance Methods

run() click to toggle source
# File lib/overcommit/hook/pre_commit/berksfile_check.rb, line 11
def run
  # Ignore if Berksfile.lock is not tracked by git
  ignored_files = execute(%w[git ls-files -o -i --exclude-standard]).stdout.split("\n")
  return :pass if ignored_files.include?(LOCK_FILE)

  result = execute(command)
  unless result.success?
    return :fail, result.stderr
  end

  :pass
end