From 5a415fd4533f6d936ee25a06dade7e3023df0bef Mon Sep 17 00:00:00 2001 From: Jonathan Brownell Date: Mon, 29 Sep 2014 10:40:06 -0700 Subject: [PATCH] Enable operating on patches with unicode chars in subject lines Currently, when run on a repository with commits containing unicode characters in their subject lines, an exception is generated when these patch descriptions are written to the todo file. This patch fixes that issue by writing the todo file using UTF-8 encoding Change-Id: I7ed61d5432cde842b09ec106011e584dd0d5a3d0 --- functional-tests/040-test_simple_rebase.sh | 3 ++- git_upstream/lib/rebaseeditor.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/functional-tests/040-test_simple_rebase.sh b/functional-tests/040-test_simple_rebase.sh index 7010389..4622ed7 100755 --- a/functional-tests/040-test_simple_rebase.sh +++ b/functional-tests/040-test_simple_rebase.sh @@ -40,7 +40,8 @@ index 170ec46..251e1dd 100644 keywords="git hpcloud workflow", EOP - git commit -a -m "Add maintainer info" --quiet || return 1 + # use smart quotes to test unicode characters in commit messages + git commit -a -m "Add “Davide Guerri” as maintainer" --quiet || return 1 git push -u origin master --quiet >/dev/null || return 1 log DEBUG "Cherry picking upstream commits" diff --git a/git_upstream/lib/rebaseeditor.py b/git_upstream/lib/rebaseeditor.py index a7e04fe..bd81cb2 100644 --- a/git_upstream/lib/rebaseeditor.py +++ b/git_upstream/lib/rebaseeditor.py @@ -20,6 +20,7 @@ from git_upstream.log import LogDedentMixin from subprocess import call import os +import codecs REBASE_EDITOR_SCRIPT = "rebase-editor" @@ -78,7 +79,7 @@ class RebaseEditor(GitMixin, LogDedentMixin): break root = None - with open(todo_file, "w") as todo: + with codecs.open(todo_file, "w", "utf-8") as todo: for commit in commits: if not root: root = commit.parents[0].hexsha