1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-21 22:32:41 +01:00

Add --never-apply-patches and --apply-patches to lint.

Summary: These flags let you force the behavior of 'arc lint' instead of
prompting. Also made the amend behavior default to false since I've screwed
this up about 300 times in the mere hours I've been using git as a primary VCS.

Test Plan: ran arc lint with these flags

Reviewers:

CC:
This commit is contained in:
epriestley 2011-01-10 14:03:12 -08:00
parent f071a55266
commit 9e77d3b3ba
2 changed files with 61 additions and 10 deletions

View file

@ -90,6 +90,8 @@ EOTEXT
'conflicts' => array( 'conflicts' => array(
'lintall' => '--nolint suppresses lint.', 'lintall' => '--nolint suppresses lint.',
'advice' => '--nolint suppresses lint.', 'advice' => '--nolint suppresses lint.',
'apply-patches' => '--nolint suppresses lint.',
'never-apply-patches' => '--nolint suppresses lint.',
), ),
), ),
'only' => array( 'only' => array(
@ -102,6 +104,8 @@ EOTEXT
'edit' => '--only does not affect revisions.', 'edit' => '--only does not affect revisions.',
'lintall' => '--only suppresses lint.', 'lintall' => '--only suppresses lint.',
'advice' => '--only suppresses lint.', 'advice' => '--only suppresses lint.',
'apply-patches' => '--only suppresses lint.',
'never-apply-patches' => '--only suppresses lint.',
'nounit' => '--only implies --nounit.', 'nounit' => '--only implies --nounit.',
'nolint' => '--only implies --nolint.', 'nolint' => '--only implies --nolint.',
), ),
@ -143,6 +147,20 @@ EOTEXT
'help' => 'help' =>
"Raise lint advice in addition to lint warnings and errors.", "Raise lint advice in addition to lint warnings and errors.",
), ),
'apply-patches' => array(
'help' =>
'Apply patches suggested by lint to the working copy without '.
'prompting.',
'conflicts' => array(
'never-apply-patches' => true,
),
),
'never-apply-patches' => array(
'help' => 'Never apply patches suggested by lint.',
'conflicts' => array(
'apply-patches' => true,
),
),
'*' => 'paths', '*' => 'paths',
); );
} }
@ -696,6 +714,12 @@ EOTEXT
if ($this->getArgument('advice')) { if ($this->getArgument('advice')) {
$argv[] = '--advice'; $argv[] = '--advice';
} }
if ($this->getArgument('apply-patches')) {
$argv[] = '--apply-patches';
}
if ($this->getArgument('never-apply-patches')) {
$argv[] = '--never-apply-patches';
}
if ($repository_api instanceof ArcanistSubversionAPI) { if ($repository_api instanceof ArcanistSubversionAPI) {
$argv = array_merge($argv, array_keys($paths)); $argv = array_merge($argv, array_keys($paths));
} else { } else {

View file

@ -53,6 +53,20 @@ EOTEXT
'help' => 'help' =>
"Override configured lint engine for this project." "Override configured lint engine for this project."
), ),
'apply-patches' => array(
'help' =>
'Apply patches suggested by lint to the working copy without '.
'prompting.',
'conflicts' => array(
'never-apply-patches' => true,
),
),
'never-apply-patches' => array(
'help' => 'Never apply patches suggested by lint.',
'conflicts' => array(
'apply-patches' => true,
),
),
'*' => 'paths', '*' => 'paths',
); );
} }
@ -146,8 +160,18 @@ EOTEXT
$results = $engine->run(); $results = $engine->run();
$apply_patches = true; if ($this->getArgument('never-apply-patches')) {
$prompt_patches = true; $apply_patches = false;
} else {
$apply_patches = true;
}
if ($this->getArgument('apply-patches')) {
$prompt_patches = false;
} else {
$prompt_patches = true;
}
$wrote_to_disk = false; $wrote_to_disk = false;
$renderer = new ArcanistLintRenderer(); $renderer = new ArcanistLintRenderer();
@ -192,15 +216,18 @@ EOTEXT
} }
if ($wrote_to_disk && ($repository_api instanceof ArcanistGitAPI)) { if ($wrote_to_disk && ($repository_api instanceof ArcanistGitAPI)) {
$amend = phutil_console_confirm( $amend = phutil_console_confirm("Amend HEAD with lint patches?");
"Amend HEAD with lint patches?", if ($amend) {
$default_no = false); execx(
if (!$amend) { '(cd %s; git commit -a --amend -C HEAD)',
throw new ArcanistUsageException("Resolve lint changes and relint."); $repository_api->getPath());
} else {
if ($this->getParentWorkflow()) {
throw new ArcanistUsageException(
"Sort out the lint changes that were applied to the working ".
"copy and relint.");
}
} }
execx(
'(cd %s; git commit -a --amend -C HEAD)',
$repository_api->getPath());
} }
$result_code = self::RESULT_OKAY; $result_code = self::RESULT_OKAY;