Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14004949
D9797.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D9797.diff
View Options
diff --git a/src/repository/api/ArcanistMercurialAPI.php b/src/repository/api/ArcanistMercurialAPI.php
--- a/src/repository/api/ArcanistMercurialAPI.php
+++ b/src/repository/api/ArcanistMercurialAPI.php
@@ -247,16 +247,7 @@
list($node, $rev, $full_author, $date, $branch, $tag,
$parents, $desc) = explode("\1", $log, 9);
- // 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();
- }
+ list ($author, $author_email) = $this->parseFullAuthor($full_author);
// NOTE: If a commit has only one parent, {parents} returns empty.
// If it has two parents, {parents} returns revs and short hashes, not
@@ -735,11 +726,32 @@
public function getAuthor() {
$full_author = $this->getMercurialConfig('ui.username');
- $email = new PhutilEmailAddress($full_author);
- $author = $email->getDisplayName();
+ list($author, $author_email) = $this->parseFullAuthor($full_author);
return $author;
}
+ /**
+ * Parse the Mercurial author field
+ *
+ * Not everyone enters their email address as a part of the username
+ * field. Try to make it work when it's obvious
+ *
+ * @param string $full_author
+ * @return array
+ */
+ protected function parseFullAuthor($full_author) {
+ if (strpos($full_author, '@') === false) {
+ $author = $full_author;
+ $author_email = null;
+ } else {
+ $email = new PhutilEmailAddress($full_author);
+ $author = $email->getDisplayName();
+ $author_email = $email->getAddress();
+ }
+
+ return array($author, $author_email);
+ }
+
public function addToCommit(array $paths) {
$this->execxLocal(
'addremove -- %Ls',
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Oct 28, 5:59 AM (2 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6738661
Default Alt Text
D9797.diff (2 KB)
Attached To
Mode
D9797: Refactor author handling in the Mercurial API
Attached
Detach File
Event Timeline
Log In to Comment