gnustavo / Git-Hooks

Framework for implementing Git (and Gerrit) hooks
http://search.cpan.org/dist/Git-Hooks/
41 stars 17 forks source link

Bugfix: The byte code marker in get_commit(). #17

Closed mikkoi closed 9 years ago

mikkoi commented 9 years ago

When creating an update hook for Jira, I found this bug. Actually, it became apparrent only when encoding to JSON. Some debug: JIRA DEBUG: $VAR1 = { 'body' => 'Finished #EAS-527: Test Commit. ' }; JIRA DEBUG: $VAR1 = '{"body":"Finished #EAS-527: Test Commit.\n\u0000"}';

gnustavo commented 9 years ago

Thank you Mikko.

Actually, your commit fixes two problems. First, it removes the trailing "\c@" character from the commit body. However, I think a better solution is simply to invoke "chomp" at the beginning of the while loop, as it will correctly chomp away the "\c@\cJ" characters at the end of the commit body.

Secondly, it passes the "--encoding=UTF-8" argument to git-rev-list, which is nice.

I'll rebase it as two commits and make them part of the next commit.

gnustavo commented 9 years ago

I've just pushed c7c0916 and cbaae23 to next.