Sha256: df646bfedc8567f2a83b788d2702413842839701ee8257865bac2293a90503c3

Contents?: true

Size: 508 Bytes

Versions: 4

Compression:

Stored size: 508 Bytes

Contents

module Overcommit::GitHook
  class Whitespace < HookSpecificCheck
    include HookRegistry

    def run_check
      paths = staged.map { |s| s.path }.join(' ')

      # Catches hard tabs
      output = `grep -Inl "\t" #{paths}`
      unless output.empty?
        return :stop, "Don't use hard tabs:\n#{output}"
      end

      # Catches trailing whitespace, conflict markers etc
      output = `git diff --check --cached`
      return :stop, output unless $?.exitstatus.zero?

      :good
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
overcommit-0.2.3 lib/overcommit/plugins/pre_commit/whitespace.rb
overcommit-0.2.2 lib/overcommit/plugins/pre_commit/whitespace.rb
overcommit-0.2.1 lib/overcommit/plugins/pre_commit/whitespace.rb
overcommit-0.2.0 lib/overcommit/plugins/pre_commit/whitespace.rb