From 476ca97e748c7e950ef3310a4029bb8527a49f0e Mon Sep 17 00:00:00 2001 From: Todd Zullinger Date: Sat, 23 Dec 2017 02:31:58 -0500 Subject: [PATCH] git (post-receive-alternativearch): use unicode for git output The commit message and diff is stored in `full_change` as a string, via `read_output()`. This is passed to `TEXT` which is a unicode string. When a commit message or diff contains non-ascii characters we get: UnicodeDecodeError: 'ascii' codec can't decode byte ... Encode git output returned from `read_output()` as a unicode string and define `full_change` as unicode for completeness. Fixes #6040. --- roles/git/hooks/files/post-receive-alternativearch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/git/hooks/files/post-receive-alternativearch b/roles/git/hooks/files/post-receive-alternativearch index 16d8cef4dd..7bc4a9a6a0 100755 --- a/roles/git/hooks/files/post-receive-alternativearch +++ b/roles/git/hooks/files/post-receive-alternativearch @@ -66,7 +66,7 @@ def read_output(cmd, abspath, input=None, keepends=False, **kw): print(err) if not keepends: out = out.rstrip('\n\r') - return out + return out.decode('utf-8') def read_git_output(args, abspath, input=None, keepends=False, **kw): @@ -164,7 +164,7 @@ def run_as_post_receive_hook(): if DEBUG: print('List of commits:', new_commits_list) - full_change = '' + full_change = u'' exclude_arch = {} for commit in new_commits_list: if DEBUG: