]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Record commit email information from `arc`
authorepriestley <git@epriestley.com>
Wed, 6 Feb 2013 04:11:20 +0000 (20:11 -0800)
committerepriestley <git@epriestley.com>
Wed, 6 Feb 2013 04:11:20 +0000 (20:11 -0800)
Summary:
Record author email information in `arc diff`, so we can recreate it in `arc patch` and elsewhere without creating any kind of email exposure issues.

In Mercurial, we currently store the whole string ("username <email@domain.com>"). Make this consistent with Git.

Test Plan: Created git and hg diffs, saw authorEmail populated.

Reviewers: btrahan, edward, vrana

Reviewed By: btrahan

CC: aran
Differential Revision: https://secure.phabricator.com/D4825

src/repository/api/ArcanistGitAPI.php
src/repository/api/ArcanistMercurialAPI.php

index 8fd29051ebec9126a4a2ab22bc92d9617055d313..2420af5a03e5a696d7b2125c490c20e229b4f901 100644 (file)
@@ -101,7 +101,7 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
         : 'log %C --format=%s --',
       $against,
       // NOTE: "%B" is somewhat new, use "%s%n%n%b" instead.
-      '%H%x01%T%x01%P%x01%at%x01%an%x01%s%x01%s%n%n%b%x02');
+      '%H%x01%T%x01%P%x01%at%x01%an%x01%aE%x01%s%x01%s%n%n%b%x02');
 
     $commits = array();
 
@@ -112,8 +112,8 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
 
     $info = explode("\2", $info);
     foreach ($info as $line) {
-      list($commit, $tree, $parents, $time, $author, $title, $message)
-        = explode("\1", trim($line), 7);
+      list($commit, $tree, $parents, $time, $author, $author_email,
+        $title, $message) = explode("\1", trim($line), 8);
       $message = rtrim($message);
 
       $commits[$commit] = array(
@@ -124,6 +124,7 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
         'author'  => $author,
         'summary' => $title,
         'message' => $message,
+        'authorEmail' => $author_email,
       );
     }
 
index 6ff488f8fbf0516708be39b2c56216697b3fced4..9f80b2be424aa1160ca42b7e38bb9ea8b512c110 100644 (file)
@@ -177,9 +177,11 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
     if ($this->localCommitInfo === null) {
       list($info) = $this->execxLocal(
         "log --template '%C' --rev %s --branch %s --",
-        "{node}\1{rev}\1{author}\1{date|rfc822date}\1".
-          "{branch}\1{tag}\1{parents}\1{desc}\2",
-        '(ancestors(.) - ancestors('.$this->getBaseCommit().'))',
+        "{node}\1{rev}\1{author|emailuser}\1{author|email}\1".
+          "{date|rfc822date}\1{branch}\1{tag}\1{parents}\1{desc}\2",
+        hgsprintf(
+          '(ancestors(.) - ancestors(%s))',
+          $this->getBaseCommit()),
         $this->getBranchName());
       $logs = array_filter(explode("\2", $info));
 
@@ -189,8 +191,8 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
 
       $commits = array();
       foreach ($logs as $log) {
-        list($node, $rev, $author, $date, $branch, $tag, $parents, $desc) =
-          explode("\1", $log);
+        list($node, $rev, $author, $author_email, $date, $branch, $tag,
+          $parents, $desc) = explode("\1", $log, 9);
 
         // NOTE: If a commit has only one parent, {parents} returns empty.
         // If it has two parents, {parents} returns revs and short hashes, not
@@ -222,6 +224,7 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
           'parents' => $commit_parents,
           'summary' => head(explode("\n", $desc)),
           'message' => $desc,
+          'authorEmail' => $author_email,
         );
 
         $last_node = $node;