jish / pre-commit

A slightly improved pre-commit hook for git
https://jish.github.io/pre-commit/
Other
796 stars 96 forks source link

Error running pre-commit on Windows #247

Closed yucombinator closed 7 years ago

yucombinator commented 7 years ago

Hi!

I've setup the gem to work with rubocop, and when I run git commit I get the following error:

c:/Ruby23/lib/ruby/gems/2.3.0/gems/pre-commit-0.30.0/lib/pre-commit/utils/staged_files.rb:37:inbinary?': undefined method >' for nil:NilClass (NoMethodError)

I'm running Ruby 2.3 on Windows and upon inspecting the file in question I noticed that the line in question is bytes = File.stat(file).blksize, which could return Nil on unsupported platforms. Is this an issue due to Windows or something else?

Thank you!

jish commented 7 years ago

I've cased the nil to an integer in https://github.com/jish/pre-commit/pull/250

jish commented 7 years ago

I released v0.31.0 which should solve this issue. https://rubygems.org/gems/pre-commit

yucombinator commented 7 years ago

Thanks!