]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Use phutil_console_prompt() instead of PhutilInteractiveEditor for excuses
authorvrana <jakubv@fb.com>
Fri, 25 May 2012 17:52:26 +0000 (10:52 -0700)
committervrana <jakubv@fb.com>
Fri, 25 May 2012 18:42:27 +0000 (11:42 -0700)
Summary:
One line is usually more than enough for these excuses.
The excuse is quite often the same as in past so history is very useful.
Prompting user right below the errors is better than writing them below prompt.

Test Plan:
Produce a lint error.
Provide an empty explanation.
Provide a non-empty explanation.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin
Differential Revision: https://secure.phabricator.com/D2580

src/workflow/diff/ArcanistDiffWorkflow.php
src/workflow/diff/__init__.php

index b6935431672327542c5df311fe1652ebb284ebb3..80a460d1834a9c7f48f13e3998d96ab9890ebaa6 100644 (file)
@@ -1117,17 +1117,11 @@ EOTEXT
       $this->unresolvedLint = $lint_workflow->getUnresolvedMessages();
       if ($continue) {
         if ($this->getArgument('excuse')) {
-          $this->unitExcuse = $this->getArgument('excuse');
+          $this->lintExcuse = $this->getArgument('excuse');
         } else {
-          $template = "\n\n# Provide an explanation for these lint failures:\n";
-          foreach ($this->unresolvedLint as $message) {
-            $template = $template."# ".
-              $message->getPath().":".
-              $message->getLine()." ".
-              $message->getCode()." :: ".
-              $message->getDescription()."\n";
-          }
-          $this->lintExcuse = $this->getErrorExcuse($template);
+          $this->lintExcuse = $this->getErrorExcuse(
+            "Provide an explanation for the lint failures:",
+            $repository_api->getScratchFilePath('lint-excuses'));
         }
       }
 
@@ -1197,22 +1191,9 @@ EOTEXT
         if ($this->getArgument('excuse')) {
           $this->unitExcuse = $this->getArgument('excuse');
         } else {
-          $template = "\n\n".
-            "# Provide an explanation for these unit test failures:\n";
-          foreach ($this->testResults as $test) {
-            $testResult = $test->getResult();
-            switch ($testResult) {
-              case ArcanistUnitTestResult::RESULT_FAIL:
-              case ArcanistUnitTestResult::RESULT_BROKEN:
-                $template = $template."# ".
-                  $test->getName()." :: ".
-                  $test->getResult()."\n";
-                break;
-              default:
-                break;
-            }
-          }
-          $this->unitExcuse = $this->getErrorExcuse($template);
+          $this->unitExcuse = $this->getErrorExcuse(
+            "Provide an explanation for the unit test failures:",
+            $repository_api->getScratchFilePath('unit-excuses'));
         }
       }
 
@@ -1226,17 +1207,15 @@ EOTEXT
     return null;
   }
 
-  private function getErrorExcuse($template) {
-    $new_template = id(new PhutilInteractiveEditor($template))
-      ->setName('error-excuse')
-      ->editInteractively();
+  private function getErrorExcuse($prompt, $history = '') {
+    $return = phutil_console_prompt($prompt, $history);
 
-    if ($new_template == $template) {
+    if ($return == '') {
       throw new ArcanistUsageException(
         "No explanation provided.");
     }
 
-    return ArcanistCommentRemover::removeComments($new_template);
+    return $return;
   }
 
 
index 51c69aa19abba9d8c5a2066e86b822f83e94b380..a7e0a3faed04325285951b70ea97479bd2270592 100644 (file)
@@ -15,7 +15,6 @@ phutil_require_module('arcanist', 'parser/commentremover');
 phutil_require_module('arcanist', 'parser/diff');
 phutil_require_module('arcanist', 'parser/diff/changetype');
 phutil_require_module('arcanist', 'repository/api/base');
-phutil_require_module('arcanist', 'unit/result');
 phutil_require_module('arcanist', 'workflow/base');
 phutil_require_module('arcanist', 'workflow/lint');
 phutil_require_module('arcanist', 'workflow/unit');