mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-22 06:42:41 +01:00
Output lint XML results to a file
Summary: Ref T8332. I find it really odd that I need to run `arc lint --everything --output xml > checkstyle.xml` and feel that it would be much more intuitive to just run `arc lint --everything --output xml` and have the output written to `checkstyle.xml`. To provide context, we are running `arc lint --everything` in a CI job and parsing the results. Test Plan: Ran `arc lint --everything --output xml` and saw the output written to file. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T8332 Differential Revision: https://secure.phabricator.com/D13570
This commit is contained in:
parent
999eb93765
commit
407954dddd
1 changed files with 30 additions and 3 deletions
|
@ -97,6 +97,11 @@ EOTEXT
|
|||
"With 'compiler', show lint warnings in suitable for your editor. ".
|
||||
"With 'xml', show lint warnings in the Checkstyle XML format."),
|
||||
),
|
||||
'outfile' => array(
|
||||
'param' => 'path',
|
||||
'help' => pht(
|
||||
'Output the linter results to a file. Defaults to stdout.'),
|
||||
),
|
||||
'only-new' => array(
|
||||
'param' => 'bool',
|
||||
'supports' => array('git', 'hg'), // TODO: svn
|
||||
|
@ -464,7 +469,19 @@ EOTEXT
|
|||
}
|
||||
|
||||
$all_autofix = true;
|
||||
$console->writeOut('%s', $renderer->renderPreamble());
|
||||
$tmp = null;
|
||||
|
||||
if ($this->getArgument('outfile') !== null) {
|
||||
$tmp = id(new TempFile())
|
||||
->setPreserveFile(true);
|
||||
}
|
||||
|
||||
$preamble = $renderer->renderPreamble();
|
||||
if ($tmp) {
|
||||
Filesystem::appendFile($tmp, $preamble);
|
||||
} else {
|
||||
$console->writeOut('%s', $preamble);
|
||||
}
|
||||
|
||||
foreach ($results as $result) {
|
||||
$result_all_autofix = $result->isAllAutofix();
|
||||
|
@ -479,7 +496,11 @@ EOTEXT
|
|||
|
||||
$lint_result = $renderer->renderLintResult($result);
|
||||
if ($lint_result) {
|
||||
$console->writeOut('%s', $lint_result);
|
||||
if ($tmp) {
|
||||
Filesystem::appendFile($tmp, $lint_result);
|
||||
} else {
|
||||
$console->writeOut('%s', $lint_result);
|
||||
}
|
||||
}
|
||||
|
||||
if ($apply_patches && $result->isPatchable()) {
|
||||
|
@ -516,7 +537,13 @@ EOTEXT
|
|||
}
|
||||
}
|
||||
|
||||
$console->writeOut('%s', $renderer->renderPostamble());
|
||||
$postamble = $renderer->renderPostamble();
|
||||
if ($tmp) {
|
||||
Filesystem::appendFile($tmp, $postamble);
|
||||
Filesystem::rename($tmp, $this->getArgument('outfile'));
|
||||
} else {
|
||||
$console->writeOut('%s', $postamble);
|
||||
}
|
||||
|
||||
if ($wrote_to_disk && $this->shouldAmendChanges) {
|
||||
if ($this->shouldAmendWithoutPrompt ||
|
||||
|
|
Loading…
Reference in a new issue