]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Provide more context in "arc diff" messages in Git
authorepriestley <git@epriestley.com>
Mon, 7 May 2012 20:18:16 +0000 (13:18 -0700)
committerepriestley <git@epriestley.com>
Mon, 7 May 2012 20:18:16 +0000 (13:18 -0700)
Summary: These are the unambiguously-good changes from D2388. Show commits included in a revision in the editor in "arc diff".

Test Plan: Ran "arc diff", saw which commits were being included.

Reviewers: nh, jungejason, vrana, btrahan

Reviewed By: btrahan

CC: aran
Maniphest Tasks: T1183

Differential Revision: https://secure.phabricator.com/D2406

src/workflow/diff/ArcanistDiffWorkflow.php

index 33a1302347e1ad4ee8fae2ecc15ccb714bf37ecd..44d0019b92ebdb308c9b803c63de05ecdc5c5e5d 100644 (file)
@@ -1341,9 +1341,13 @@ EOTEXT
 
     $template_is_default = false;
     $notes = array();
+    $included = array();
 
-    if (!$template) {
-      list($fields, $notes) = $this->getDefaultCreateFields();
+    list($fields, $notes, $included) = $this->getDefaultCreateFields();
+    if ($template) {
+      $fields = array();
+      $notes = array();
+    } else {
       if (!$fields) {
         $template_is_default = true;
       }
@@ -1357,15 +1361,38 @@ EOTEXT
         ));
     }
 
-    $issues = array(
-      'NEW DIFFERENTIAL REVISION',
-      'Describe the changes in this new revision.',
-      '',
-      'arc could not identify any existing revision in your working copy.',
-      'If you intended to update an existing revision, use:',
-      '',
-      '  $ arc diff --update <revision>',
-    );
+    if ($included) {
+      foreach ($included as $k => $commit) {
+        $included[$k] = '        '.$commit;
+      }
+      $included = array_merge(
+        array(
+          "",
+          "Included commits:",
+          "",
+        ),
+        $included,
+        array(
+          "",
+        ));
+    } else {
+      $included = array(
+        '',
+      );
+    }
+
+    $issues = array_merge(
+      array(
+        'NEW DIFFERENTIAL REVISION',
+        'Describe the changes in this new revision.',
+      ),
+      $included,
+      array(
+        'arc could not identify any existing revision in your working copy.',
+        'If you intended to update an existing revision, use:',
+        '',
+        '  $ arc diff --update <revision>',
+      ));
     if ($notes) {
       $issues = array_merge($issues, array(''), $notes);
     }
@@ -1580,7 +1607,7 @@ EOTEXT
   }
 
   private function getDefaultCreateFields() {
-    $empty = array(array(), array());
+    $empty = array(array(), array(), array());
 
     if ($this->isRawDiffSource()) {
       return $empty;
@@ -1599,6 +1626,7 @@ EOTEXT
   private function getGitCreateFields() {
     $conduit = $this->getConduit();
     $changes = $this->getLocalGitCommitMessages();
+    $included = array();
 
     $commits = array();
     foreach ($changes as $key => $change) {
@@ -1609,6 +1637,9 @@ EOTEXT
     foreach ($commits as $hash => $text) {
       $messages[$hash] = ArcanistDifferentialCommitMessage::newFromRawCorpus(
         $text);
+
+      $first_line = head(explode("\n", trim($text)));
+      $included[] = substr($hash, 0, 12).' '.$first_line;
     }
 
     $fields = array();
@@ -1632,7 +1663,7 @@ EOTEXT
       }
     }
 
-    return array($fields, $notes);
+    return array($fields, $notes, $included);
   }
 
   private function getDefaultUpdateMessage() {