Class: PreCommit::WhiteSpaceCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/pre-commit/checks/whitespace_check.rb

Class Method Summary collapse

Class Method Details

.call(_) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/pre-commit/checks/whitespace_check.rb', line 3

def self.call(_)
  errors = `git diff-index --check --cached head -- 2>&1`
  return if $?.success?

  # Initial commit: diff against the empty tree object
  if errors =~ /fatal: bad revision 'head'/
    errors = `git diff-index --check --cached 4b825dc642cb6eb9a060e54bf8d69288fbee4904 -- 2>&1`
    return if $?.success?
  end

  errors
end