mirror of
https://we.phorge.it/source/arcanist.git
synced 2025-04-01 15:08:13 +02:00
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
This commit is contained in:
parent
fed73b75cf
commit
051cbcb8e9
2 changed files with 11 additions and 33 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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');
|
||||
|
|
Loading…
Add table
Reference in a new issue