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
This commit is contained in:
James E. Blair 2014-09-05 09:25:05 -07:00
parent 4cdf87687d
commit 3e23dbad0f
1 changed files with 8 additions and 6 deletions

View File

@ -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.