mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-26 00:32:41 +01:00
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 <rvanvelzen@company.com>', '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
This commit is contained in:
parent
d7541c70dd
commit
680ec3670c
1 changed files with 10 additions and 3 deletions
|
@ -247,9 +247,16 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
|
||||||
list($node, $rev, $full_author, $date, $branch, $tag,
|
list($node, $rev, $full_author, $date, $branch, $tag,
|
||||||
$parents, $desc) = explode("\1", $log, 9);
|
$parents, $desc) = explode("\1", $log, 9);
|
||||||
|
|
||||||
$email = new PhutilEmailAddress($full_author);
|
// Not everyone enters their email address as a part of the username
|
||||||
$author = $email->getDisplayName();
|
// field. Try to make it work when it's obvious
|
||||||
$author_email = $email->getAddress();
|
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.
|
// NOTE: If a commit has only one parent, {parents} returns empty.
|
||||||
// If it has two parents, {parents} returns revs and short hashes, not
|
// If it has two parents, {parents} returns revs and short hashes, not
|
||||||
|
|
Loading…
Reference in a new issue