From: vrana Date: Fri, 25 May 2012 17:52:26 +0000 (-0700) Subject: Use phutil_console_prompt() instead of PhutilInteractiveEditor for excuses X-Git-Tag: conduit-6~299 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=051cbcb8e9f78abe7d33ca4023f99ebb36c55d74;p=arcanist.git Use phutil_console_prompt() instead of PhutilInteractiveEditor for excuses 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 --- diff --git a/src/workflow/diff/ArcanistDiffWorkflow.php b/src/workflow/diff/ArcanistDiffWorkflow.php index b6935431..80a460d1 100644 --- a/src/workflow/diff/ArcanistDiffWorkflow.php +++ b/src/workflow/diff/ArcanistDiffWorkflow.php @@ -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; } diff --git a/src/workflow/diff/__init__.php b/src/workflow/diff/__init__.php index 51c69aa1..a7e0a3fa 100644 --- a/src/workflow/diff/__init__.php +++ b/src/workflow/diff/__init__.php @@ -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');