private $commitHookMode = false;
private $hookAPI;
+ private $enableAsyncLint = false;
+ private $postponedLinters = array();
+
public function __construct() {
}
return $this->hookAPI;
}
+ public function setEnableAsyncLint($enable_async_lint) {
+ $this->enableAsyncLint = $enable_async_lint;
+ return $this;
+ }
+
+ public function getEnableAsyncLint() {
+ return $this->enableAsyncLint;
+ }
+
public function loadData($path) {
if (!isset($this->fileData[$path])) {
if ($this->getCommitHookMode()) {
return array($line, $char);
}
+ public function getPostponedLinters() {
+ return $this->postponedLinters;
+ }
+
+ public function setPostponedLinters(array $linters) {
+ $this->postponedLinters = $linters;
+ return $this;
+ }
}
private $diffID;
private $revisionID;
private $unitWorkflow;
+ private $lintWorkflow;
+ private $postponedLinters;
public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
$this->diffID = $diff_info['diffid'];
+ $this->dispatchDiffWasCreatedEvent($diff_info['diffid']);
+
if ($this->unitWorkflow) {
$this->unitWorkflow->setDifferentialDiffID($diff_info['diffid']);
}
$argv[] = $repository_api->getRelativeCommit();
}
$lint_workflow = $this->buildChildWorkflow('lint', $argv);
+ $this->lintWorkflow = $lint_workflow;
if ($this->shouldAmend()) {
// TODO: We should offer to create a checkpoint commit.
"Lint issued unresolved errors!",
'lint-excuses');
break;
+ case ArcanistLintWorkflow::RESULT_POSTPONED:
+ echo phutil_console_format(
+ "<bg:yellow>** LINT POSTPONED **</bg> ".
+ "Lint results are postponed.\n");
+ break;
}
$this->unresolvedLint = $lint_workflow->getUnresolvedMessages();
+ $this->postponedLinters = $lint_workflow->getPostponedLinters();
return $lint_result;
} catch (ArcanistNoEngineException $ex) {
ArcanistLintWorkflow::RESULT_ERRORS => 'fail',
ArcanistLintWorkflow::RESULT_WARNINGS => 'warn',
ArcanistLintWorkflow::RESULT_SKIP => 'skip',
+ ArcanistLintWorkflow::RESULT_POSTPONED => 'postponed',
);
return idx($map, $lint_result, 'none');
}
* @task diffprop
*/
private function updateLintDiffProperty() {
- if (!$this->unresolvedLint) {
- return;
- }
- $data = array();
- foreach ($this->unresolvedLint as $message) {
- $data[] = array(
- 'path' => $message->getPath(),
- 'line' => $message->getLine(),
- 'char' => $message->getChar(),
- 'code' => $message->getCode(),
- 'severity' => $message->getSeverity(),
- 'name' => $message->getName(),
- 'description' => $message->getDescription(),
- );
+ if ($this->unresolvedLint) {
+ $data = array();
+ foreach ($this->unresolvedLint as $message) {
+ $data[] = array(
+ 'path' => $message->getPath(),
+ 'line' => $message->getLine(),
+ 'char' => $message->getChar(),
+ 'code' => $message->getCode(),
+ 'severity' => $message->getSeverity(),
+ 'name' => $message->getName(),
+ 'description' => $message->getDescription(),
+ );
+ }
+
+ $this->updateDiffProperty('arc:lint', json_encode($data));
+ if (strlen($this->lintExcuse)) {
+ $this->updateDiffProperty('arc:lint-excuse',
+ json_encode($this->lintExcuse));
+ }
}
- $this->updateDiffProperty('arc:lint', json_encode($data));
- if (strlen($this->lintExcuse)) {
- $this->updateDiffProperty('arc:lint-excuse',
- json_encode($this->lintExcuse));
+ $postponed = $this->postponedLinters;
+ if ($postponed) {
+ $this->updateDiffProperty('arc:lint-postponed', json_encode($postponed));
}
+
}
return $event->getValue('fields');
}
+ private function dispatchDiffWasCreatedEvent($diff_id) {
+ $event = new PhutilEvent(
+ ArcanistEventType::TYPE_DIFF_WASCREATED,
+ array(
+ 'diffID' => $diff_id,
+ ));
+
+ PhutilEventEngine::dispatchEvent($event);
+ }
}
const RESULT_WARNINGS = 1;
const RESULT_ERRORS = 2;
const RESULT_SKIP = 3;
+ const RESULT_POSTPONED = 4;
private $unresolvedMessages;
private $shouldAmendChanges = false;
private $shouldAmendWithoutPrompt = false;
private $shouldAmendAutofixesWithoutPrompt = false;
+ private $engine;
+ private $postponedLinters;
public function setShouldAmendChanges($should_amend) {
$this->shouldAmendChanges = $should_amend;
}
$engine = newv($engine, array());
+ $this->engine = $engine;
$engine->setWorkingCopy($working_copy);
if ($this->getArgument('advice')) {
}
}
+ // Enable possible async linting only for 'arc diff' not 'arc unit'
+ if ($this->getParentWorkflow()) {
+ $engine->setEnableAsyncLint(true);
+ } else {
+ $engine->setEnableAsyncLint(false);
+ }
+
$results = $engine->run();
+ // It'd be nice to just return a single result from the run method above
+ // which contains both the lint messages and the postponed linters.
+ // However, to maintain compatibility with existing lint subclasses, use
+ // a separate method call to grab the postponed linters.
+ $this->postponedLinters = $engine->getPostponedLinters();
+
if ($this->getArgument('never-apply-patches')) {
$apply_patches = false;
} else {
$result_code = self::RESULT_ERRORS;
} else if ($has_warnings) {
$result_code = self::RESULT_WARNINGS;
+ } else if (!empty($this->postponedLinters)) {
+ $result_code = self::RESULT_POSTPONED;
} else {
$result_code = self::RESULT_OKAY;
}
return $this->unresolvedMessages;
}
+ public function getPostponedLinters() {
+ return $this->postponedLinters;
+ }
+
}