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

diff_to_html.rb:318:in `split': invalid byte sequence in US-ASCII (ArgumentError) #103

Closed
mfn opened this issue Oct 11, 2011 · 5 comments
Closed

Comments

@mfn
Copy link

mfn commented Oct 11, 2011

When pushing commits to repository containing e.g. UTF8 characters, I get this:

remote: /usr/local/rvm/gems/ruby-1.9.2-p290/gems/git-commit-notifier-0.10.2/lib/git_commit_notifier/diff_to_html.rb:318:in `split': invalid byte sequence in US-ASCII (ArgumentError)
remote:         from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/git-commit-notifier-0.10.2/lib/git_commit_notifier/diff_to_html.rb:318:in `extract_commit_info_from_git_show_output'
remote:         from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/git-commit-notifier-0.10.2/lib/git_commit_notifier/diff_to_html.rb:433:in `diff_for_commit'
remote:         from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/git-commit-notifier-0.10.2/lib/git_commit_notifier/diff_to_html.rb:509:in `block in diff_between_revisions'
remote:         from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/git-commit-notifier-0.10.2/lib/git_commit_notifier/diff_to_html.rb:506:in `each'
remote:         from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/git-commit-notifier-0.10.2/lib/git_commit_notifier/diff_to_html.rb:506:in `diff_between_revisions'
remote:         from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/git-commit-notifier-0.10.2/lib/git_commit_notifier/commit_hook.rb:87:in `run'
remote:         from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/git-commit-notifier-0.10.2/lib/git_commit_notifier/executor.rb:14:in `run!'
remote:         from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/git-commit-notifier-0.10.2/bin/git-commit-notifier:15:in `<top (required)>'
remote:         from /usr/local/rvm/gems/ruby-1.9.2-p290/bin/git-commit-notifier:19:in `load'
remote:         from /usr/local/rvm/gems/ruby-1.9.2-p290/bin/git-commit-notifier:19:in `<main>'

What I mean is that the diff change I did to one file contained UTF8 characters on which the diff_to_html library chokes.

@mfn
Copy link
Author

mfn commented Oct 11, 2011

Btw, works fine with 1.8.7 ; I've reverted now to Ruby 1.8.

I just realized this is kind of the same like Issue 103

@akzhan
Copy link
Member

akzhan commented Oct 11, 2011

Thanks for the report.

@mfn
Copy link
Author

mfn commented Oct 11, 2011

Some more information:

I tried to reproduce this problem in another environment and it worked without problems. Trying to narrow it down, I compared the locale output on both environments. In the working environment it was all set up to en_US.UTF-8. In the "problematic" environment, which is using git-http-backend via apache2, no specific locale was set, it all defaulted to POSIX.

I was able to fix this on my end up setting the post-receive hook this way:

LANG=en_US.UTF-8 GEM_HOME=... .../git-commit-notifier ...git-notifier-config.yml

Or, to describe it the other way: I can easily reproduce this problem locally when I set LANG=POSIX in the environment executing git-commit-notifier.

I found a workaround by always forcing UTF-8, because the git commands in use (git log, git show) default to UTF-8. See https://github.com/bitboxer/git-commit-notifier/pull/105 .

@mfn
Copy link
Author

mfn commented Oct 14, 2011

I still have the same issue, albeit the error message is a bit different; it now references UTF-8 instead of US-ASCII; tested with master @ 36122d0 :

$ rm previously.txt; src/ruby/git-commit-notifier/local-run.rb example.yml badc3992480cbd645aa67f360c8fd7d5516fe286 b232ff2f08a24bae1c6c55df1784ccbd64291611
Sending mail...
#<Encoding:UTF-8>
src/ruby/git-commit-notifier/lib/git_commit_notifier/diff_to_html.rb:319:in `split': invalid byte sequence in UTF-8 (ArgumentError)
        from src/ruby/git-commit-notifier/lib/git_commit_notifier/diff_to_html.rb:319:in `extract_commit_info_from_git_show_output'
        from src/ruby/git-commit-notifier/lib/git_commit_notifier/diff_to_html.rb:434:in `diff_for_commit'
        from src/ruby/git-commit-notifier/lib/git_commit_notifier/diff_to_html.rb:515:in `block in diff_between_revisions'
        from src/ruby/git-commit-notifier/lib/git_commit_notifier/diff_to_html.rb:512:in `each'
        from src/ruby/git-commit-notifier/lib/git_commit_notifier/diff_to_html.rb:512:in `diff_between_revisions'
        from src/ruby/git-commit-notifier/lib/git_commit_notifier/commit_hook.rb:121:in `run'
        from src/ruby/git-commit-notifier/lib/git_commit_notifier/executor.rb:23:in `run!'
        from src/ruby/git-commit-notifier/local-run.rb:22:in `<main>'

(I can't reopen the issue, no permissions)

@mfn
Copy link
Author

mfn commented Oct 14, 2011

In case you want to test it yourself, here's the dummy repository I used for testing (it's a git repos in a tar.bz2): http://my-serve.rs/tmp/foo.tar.bz2 ; it contains differences in files as well as commit messages with non-US-ASCII characters. The above shown command can be simply applied to it. This was tested with locale en_US.UTF-8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants