mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-26 08:42:40 +01:00
Simplify diff excuses
Summary: The theory is that lint and unit errors are rare with no false positives. Our reality is currently different. This diff removes the question for providing explanation before actually providing it. I hope that the wording is not confusing. It also simplifies the code with less copy/paste errors (not me!) potential. Test Plan: `arc diff` on code with lint and unit errors. Repeat with `--excuse .`. Reviewers: epriestley Reviewed By: epriestley CC: aran, Koolvin, meitros Differential Revision: https://secure.phabricator.com/D2631
This commit is contained in:
parent
693943c1a4
commit
2ba9f34f5c
1 changed files with 23 additions and 50 deletions
|
@ -1092,46 +1092,26 @@ EOTEXT
|
||||||
|
|
||||||
$lint_result = $lint_workflow->run();
|
$lint_result = $lint_workflow->run();
|
||||||
|
|
||||||
$continue = false;
|
|
||||||
switch ($lint_result) {
|
switch ($lint_result) {
|
||||||
case ArcanistLintWorkflow::RESULT_OKAY:
|
case ArcanistLintWorkflow::RESULT_OKAY:
|
||||||
echo phutil_console_format(
|
echo phutil_console_format(
|
||||||
"<bg:green>** LINT OKAY **</bg> No lint problems.\n");
|
"<bg:green>** LINT OKAY **</bg> No lint problems.\n");
|
||||||
break;
|
break;
|
||||||
case ArcanistLintWorkflow::RESULT_WARNINGS:
|
case ArcanistLintWorkflow::RESULT_WARNINGS:
|
||||||
$msg = "Lint issued unresolved warnings. ";
|
$this->lintExcuse = $this->getErrorExcuse(
|
||||||
$msg .= $this->getArgument('excuse')
|
"Lint issued unresolved warnings.",
|
||||||
? "Ignore them?"
|
$repository_api->getScratchFilePath('lint-excuses'));
|
||||||
: "Provide explanation and continue?";
|
|
||||||
$continue = phutil_console_confirm($msg);
|
|
||||||
if (!$continue) {
|
|
||||||
throw new ArcanistUserAbortException();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case ArcanistLintWorkflow::RESULT_ERRORS:
|
case ArcanistLintWorkflow::RESULT_ERRORS:
|
||||||
echo phutil_console_format(
|
echo phutil_console_format(
|
||||||
"<bg:red>** LINT ERRORS **</bg> Lint raised errors!\n");
|
"<bg:red>** LINT ERRORS **</bg> Lint raised errors!\n");
|
||||||
$msg = "Lint issued unresolved errors! ";
|
$this->lintExcuse = $this->getErrorExcuse(
|
||||||
$msg .= $this->getArgument('excuse')
|
"Lint issued unresolved errors!",
|
||||||
? "Ignore lint errors?"
|
$repository_api->getScratchFilePath('lint-excuses'));
|
||||||
: "Provide explanation and continue?";
|
|
||||||
$continue = phutil_console_confirm($msg);
|
|
||||||
if (!$continue) {
|
|
||||||
throw new ArcanistUserAbortException();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->unresolvedLint = $lint_workflow->getUnresolvedMessages();
|
$this->unresolvedLint = $lint_workflow->getUnresolvedMessages();
|
||||||
if ($continue) {
|
|
||||||
if ($this->getArgument('excuse')) {
|
|
||||||
$this->lintExcuse = $this->getArgument('excuse');
|
|
||||||
} else {
|
|
||||||
$this->lintExcuse = $this->getErrorExcuse(
|
|
||||||
"Explanation:",
|
|
||||||
$repository_api->getScratchFilePath('lint-excuses'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $lint_result;
|
return $lint_result;
|
||||||
} catch (ArcanistNoEngineException $ex) {
|
} catch (ArcanistNoEngineException $ex) {
|
||||||
|
@ -1165,7 +1145,7 @@ EOTEXT
|
||||||
}
|
}
|
||||||
$this->unitWorkflow = $this->buildChildWorkflow('unit', $argv);
|
$this->unitWorkflow = $this->buildChildWorkflow('unit', $argv);
|
||||||
$unit_result = $this->unitWorkflow->run();
|
$unit_result = $this->unitWorkflow->run();
|
||||||
$explain = false;
|
|
||||||
switch ($unit_result) {
|
switch ($unit_result) {
|
||||||
case ArcanistUnitWorkflow::RESULT_OKAY:
|
case ArcanistUnitWorkflow::RESULT_OKAY:
|
||||||
echo phutil_console_format(
|
echo phutil_console_format(
|
||||||
|
@ -1182,28 +1162,13 @@ EOTEXT
|
||||||
case ArcanistUnitWorkflow::RESULT_FAIL:
|
case ArcanistUnitWorkflow::RESULT_FAIL:
|
||||||
echo phutil_console_format(
|
echo phutil_console_format(
|
||||||
"<bg:red>** UNIT ERRORS **</bg> Unit testing raised errors!\n");
|
"<bg:red>** UNIT ERRORS **</bg> Unit testing raised errors!\n");
|
||||||
$msg = "Unit test results include failures! ";
|
$this->unitExcuse = $this->getErrorExcuse(
|
||||||
$msg .= $this->getArgument('excuse')
|
"Unit test results include failures!",
|
||||||
? "Ignore test failures?"
|
$repository_api->getScratchFilePath('unit-excuses'));
|
||||||
: "Explain test failures and continue?";
|
|
||||||
$continue = phutil_console_confirm($msg);
|
|
||||||
if (!$continue) {
|
|
||||||
throw new ArcanistUserAbortException();
|
|
||||||
}
|
|
||||||
$explain = true;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->testResults = $this->unitWorkflow->getTestResults();
|
$this->testResults = $this->unitWorkflow->getTestResults();
|
||||||
if ($explain) {
|
|
||||||
if ($this->getArgument('excuse')) {
|
|
||||||
$this->unitExcuse = $this->getArgument('excuse');
|
|
||||||
} else {
|
|
||||||
$this->unitExcuse = $this->getErrorExcuse(
|
|
||||||
"Explanation:",
|
|
||||||
$repository_api->getScratchFilePath('unit-excuses'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $unit_result;
|
return $unit_result;
|
||||||
} catch (ArcanistNoEngineException $ex) {
|
} catch (ArcanistNoEngineException $ex) {
|
||||||
|
@ -1216,13 +1181,21 @@ EOTEXT
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getErrorExcuse($prompt, $history = '') {
|
private function getErrorExcuse($prompt, $history = '') {
|
||||||
$return = phutil_console_prompt($prompt, $history);
|
if ($this->getArgument('excuse')) {
|
||||||
|
$prompt .= " Ignore them?";
|
||||||
if ($return == '') {
|
if (!phutil_console_confirm($prompt)) {
|
||||||
throw new ArcanistUsageException(
|
throw new ArcanistUserAbortException();
|
||||||
"No explanation provided.");
|
}
|
||||||
|
return $this->getArgument('excuse');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$prompt .= " Provide explanation to continue or press Enter to abort.";
|
||||||
|
echo "\n\n";
|
||||||
|
echo phutil_console_format($prompt);
|
||||||
|
$return = phutil_console_prompt("Explanation:", $history);
|
||||||
|
if ($return == '') {
|
||||||
|
throw new ArcanistUserAbortException();
|
||||||
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue