Sha256: 4efbd7de42d4f9d76b2b35c4a2e49868670f83f2607a4b6cd5af8cf760f850b2

Contents?: true

Size: 760 Bytes

Versions: 5

Compression:

Stored size: 760 Bytes

Contents

module Overcommit::Hook::PreCommit
  # Check if local Gemfile.lock matches Gemfile when either changes, unless
  # Gemfile.lock is ignored by git.
  class BundleCheck < Base
    LOCK_FILE = 'Gemfile.lock'

    def run
      # Ignore if Gemfile.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(%W[#{executable} check])
      unless result.success?
        return :fail, result.stdout
      end

      result = execute(%w[git diff --quiet --] + [LOCK_FILE])
      unless result.success?
        return :fail, "#{LOCK_FILE} is not up-to-date -- run `#{executable} check`"
      end

      :pass
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
jawshooah-overcommit-0.22.0 lib/overcommit/hook/pre_commit/bundle_check.rb
overcommit-0.21.0 lib/overcommit/hook/pre_commit/bundle_check.rb
overcommit-0.20.0 lib/overcommit/hook/pre_commit/bundle_check.rb
overcommit-0.19.0 lib/overcommit/hook/pre_commit/bundle_check.rb
overcommit-0.18.0 lib/overcommit/hook/pre_commit/bundle_check.rb