From 0d5b0f21ad2bc03988b007b017e44d4210ab9645 Mon Sep 17 00:00:00 2001 From: David Reuss Date: Fri, 28 Oct 2011 08:06:03 -0700 Subject: [PATCH] Convert author/message encoding if not UTF-8 Test Plan: used the reparse.php script for reparsing commit messages and saw the correct author name (and mapped correctly as a phabricator user) in diffusion. Reviewers: epriestley Reviewed By: epriestley CC: aran, epriestley Differential Revision: 1059 --- ...PhabricatorRepositoryGitCommitMessageParserWorker.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/applications/repository/worker/commitmessageparser/git/PhabricatorRepositoryGitCommitMessageParserWorker.php b/src/applications/repository/worker/commitmessageparser/git/PhabricatorRepositoryGitCommitMessageParserWorker.php index 420c80f0bf..7ac096d0d8 100644 --- a/src/applications/repository/worker/commitmessageparser/git/PhabricatorRepositoryGitCommitMessageParserWorker.php +++ b/src/applications/repository/worker/commitmessageparser/git/PhabricatorRepositoryGitCommitMessageParserWorker.php @@ -26,10 +26,15 @@ class PhabricatorRepositoryGitCommitMessageParserWorker // NOTE: %B was introduced somewhat recently in git's history, so pull // commit message information with %s and %b instead. list($info) = $repository->execxLocalCommand( - 'log -n 1 --pretty=format:%%an%%x00%%s%%n%%n%%b %s', + 'log -n 1 --pretty=format:%%e%%x00%%an%%x00%%s%%n%%n%%b %s', $commit->getCommitIdentifier()); - list($author, $message) = explode("\0", $info); + list($encoding, $author, $message) = explode("\0", $info); + + if ($encoding != "UTF-8") { + $author = mb_convert_encoding($author, 'UTF-8', $encoding); + $message = mb_convert_encoding($message, 'UTF-8', $encoding); + } // Make sure these are valid UTF-8. $author = phutil_utf8ize($author);