cypher / git-ruby-syntax-check

Checks the syntax of all changed ruby files is valid before allowing a commit
MIT License
70 stars 16 forks source link

Suddenly started to get errors when committing #7

Open NielsKSchjoedt opened 10 years ago

NielsKSchjoedt commented 10 years ago

Without any indication as to why, I suddenly started to get the following errors when I commit:

.git/hooks/pre-commit:40:in `split': invalid byte sequence in US-ASCII (ArgumentError)
    from .git/hooks/pre-commit:40:in `block (2 levels) in <main>'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open3.rb:217:in `popen_run'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open3.rb:99:in `popen3'
    from .git/hooks/pre-commit:39:in `block in <main>'
    from .git/hooks/pre-commit:28:in `each'
    from .git/hooks/pre-commit:28:in `inject'
    from .git/hooks/pre-commit:28:in `<main>'
 (1)

If I then add # encoding: utf-8 to the top of the file, I get:

.git/hooks/pre-commit: line 12: require: command not found
.git/hooks/pre-commit: line 13: include: command not found
.git/hooks/pre-commit: line 16: syntax error near unexpected token `('
.git/hooks/pre-commit: line 16: `stop_on_warnings = (`git config --bool hooks.stop-on-warnings` != "false\n")'
 (1)

I haven't changed anything in the script, it's exactly like the one here in the repository.

cypher commented 10 years ago

Did you add the "encoding" line at the very first line? This is where the she-bang is supposed to be, and from the second error message, it looks like that broke the script.

I've committed an update to the script, could you try the updated version?