Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid UTF-8 Encoding Issue for LineEndings Check #492

Closed
jfelchner opened this issue May 8, 2017 · 3 comments
Closed

Invalid UTF-8 Encoding Issue for LineEndings Check #492

jfelchner opened this issue May 8, 2017 · 3 comments
Labels

Comments

@jfelchner
Copy link
Contributor

On files with invalid UTF-8 Encoding (I'm assuming such as binary files although I can't tell which file it is from the error output), the LineEndings check blows up:

~/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/overcommit-0.39.1/lib/overcommit/hook/pre_commit/line_endings.rb:13:in `gsub!'
~/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/overcommit-0.39.1/lib/overcommit/hook/pre_commit/line_endings.rb:13:in `block (2 levels) in run'
~/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/overcommit-0.39.1/lib/overcommit/hook/pre_commit/line_endings.rb:11:in `each_line'
~/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/overcommit-0.39.1/lib/overcommit/hook/pre_commit/line_endings.rb:11:in `block in run'
~/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/overcommit-0.39.1/lib/overcommit/hook/pre_commit/line_endings.rb:9:in `map'
~/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/overcommit-0.39.1/lib/overcommit/hook/pre_commit/line_endings.rb:9:in `run'
~/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/overcommit-0.39.1/lib/overcommit/hook/base.rb:45:in `block in run_and_transform'
~/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/overcommit-0.39.1/lib/overcommit/utils.rb:260:in `with_environment'
~/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/overcommit-0.39.1/lib/overcommit/hook/base.rb:45:in `run_and_transform'
~/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/overcommit-0.39.1/lib/overcommit/hook_runner.rb:155:in `run_hook'
~/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/overcommit-0.39.1/lib/overcommit/hook_runner.rb:88:in `block in consume'
~/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/overcommit-0.39.1/lib/overcommit/hook_runner.rb:85:in `loop'
~/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/overcommit-0.39.1/lib/overcommit/hook_runner.rb:85:in `consume'
@jfelchner jfelchner changed the title Invalid UTF-8 Encoding Issue Invalid UTF-8 Encoding Issue for LineEndings Check May 8, 2017
@sds sds added the bug label May 18, 2017
@sds
Copy link
Owner

sds commented May 18, 2017

Hey @jfelchner, thanks for the report.

Can you dig up what the actual exception thrown was? We could work around this by gracefully catching such exceptions and ignoring those files if they are indeed binary files.

I'm not aware of a good cross-platform way to test whether a file is "binary", so my preference would be to just degrade gracefully in a case where we hit an encoding problem.

@jfelchner
Copy link
Contributor Author

UGH. Why didn't I add that for you all? 😧 I believe it was ArgumentError: invalid byte sequence in UTF-8 but I honestly can't even remember the project this happened in. I'm sure when whichever client needs more work done I'll find it again. But I'm pretty sure that was it.

@jfelchner
Copy link
Contributor Author

@sds this should help. Committing this file throws the error.

invalid

@sds sds closed this as completed in afdebb3 May 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants