From 680ec3670cd9d9195debf3e9b674b1b232156e61 Mon Sep 17 00:00:00 2001 From: Richard van Velzen Date: Tue, 17 Jun 2014 11:46:42 -0700 Subject: [PATCH] Don't parse mercurial usernames without email address as an email address Summary: This leads to information being lost when others do `arc patch` because the name is used as the email address. For example: username = Richard van Velzen Would give: 'authorName' => null, 'authorEmail' => 'Richard van Velzen' Test Plan: ran it through my head a couple of times, and tested it with the common options which all gave the expected result: 'rvanvelzen@company.com', 'Richard van Velzen', 'Richard van Velzen ', 'Richard van Velzen rvanvelzen@company.com', Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D9605 --- src/repository/api/ArcanistMercurialAPI.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/repository/api/ArcanistMercurialAPI.php b/src/repository/api/ArcanistMercurialAPI.php index 7efb257d..5fd7e642 100644 --- a/src/repository/api/ArcanistMercurialAPI.php +++ b/src/repository/api/ArcanistMercurialAPI.php @@ -247,9 +247,16 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { list($node, $rev, $full_author, $date, $branch, $tag, $parents, $desc) = explode("\1", $log, 9); - $email = new PhutilEmailAddress($full_author); - $author = $email->getDisplayName(); - $author_email = $email->getAddress(); + // Not everyone enters their email address as a part of the username + // field. Try to make it work when it's obvious + if (strpos($full_author, '@') === false) { + $author = $full_author; + $author_email = null; + } else { + $email = new PhutilEmailAddress($full_author); + $author = $email->getDisplayName(); + $author_email = $email->getAddress(); + } // NOTE: If a commit has only one parent, {parents} returns empty. // If it has two parents, {parents} returns revs and short hashes, not