From 3e23dbad0f485fd8243d5a0ae985aaa86de43e51 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Fri, 5 Sep 2014 09:25:05 -0700 Subject: [PATCH] Handle unicode emails in git commits This should probably never happen, but it has anyway, so assume the email field is a utf8 string. This should avoid crashing in case someone has a utf8 email, but may not be a complete solution to the case that an email is in a non-ascii, non-utf8 charset. Change-Id: I95ed91e5fdfe35b73550e1824e609a0b1d388b3a --- gertty/gitrepo.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/gertty/gitrepo.py b/gertty/gitrepo.py index 3e43224..6a3efc0 100644 --- a/gertty/gitrepo.py +++ b/gertty/gitrepo.py @@ -83,12 +83,14 @@ class CommitContext(object): commit.authored_date, commit.author_tz_offset) commit_date = self.decorateGitTime( commit.committed_date, commit.committer_tz_offset) - return ["Parent: %s\n" % parentsha, - "Author: %s <%s>\n" % (author.name, author.email), - "AuthorDate: %s\n" % author_date, - "Commit: %s <%s>\n" % (committer.name, committer.email), - "CommitDate: %s\n" % commit_date, - "\n"] + commit.message.splitlines(True) + return [u"Parent: %s\n" % parentsha, + u"Author: %s <%s>\n" % (author.name, + unicode(author.email, 'utf8')), + u"AuthorDate: %s\n" % author_date, + u"Commit: %s <%s>\n" % (committer.name, + unicode(committer.email, 'utf')), + u"CommitDate: %s\n" % commit_date, + u"\n"] + commit.message.splitlines(True) def __init__(self, old, new): """Create a CommitContext.