1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-25 00:02:40 +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(
'lintall' => '--nolint suppresses lint.',
'advice' => '--nolint suppresses lint.',
'apply-patches' => '--nolint suppresses lint.',
'never-apply-patches' => '--nolint suppresses lint.',
),
),
'only' => array(
@ -102,6 +104,8 @@ EOTEXT
'edit' => '--only does not affect revisions.',
'lintall' => '--only suppresses lint.',
'advice' => '--only suppresses lint.',
'apply-patches' => '--only suppresses lint.',
'never-apply-patches' => '--only suppresses lint.',
'nounit' => '--only implies --nounit.',
'nolint' => '--only implies --nolint.',
),
@ -143,6 +147,20 @@ EOTEXT
'help' =>
"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',
);
}
@ -696,6 +714,12 @@ EOTEXT
if ($this->getArgument('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) {
$argv = array_merge($argv, array_keys($paths));
} else {

View file

@ -53,6 +53,20 @@ EOTEXT
'help' =>
"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',
);
}
@ -146,8 +160,18 @@ EOTEXT
$results = $engine->run();
$apply_patches = true;
$prompt_patches = true;
if ($this->getArgument('never-apply-patches')) {
$apply_patches = false;
} else {
$apply_patches = true;
}
if ($this->getArgument('apply-patches')) {
$prompt_patches = false;
} else {
$prompt_patches = true;
}
$wrote_to_disk = false;
$renderer = new ArcanistLintRenderer();
@ -192,15 +216,18 @@ EOTEXT
}
if ($wrote_to_disk && ($repository_api instanceof ArcanistGitAPI)) {
$amend = phutil_console_confirm(
"Amend HEAD with lint patches?",
$default_no = false);
if (!$amend) {
throw new ArcanistUsageException("Resolve lint changes and relint.");
$amend = phutil_console_confirm("Amend HEAD with lint patches?");
if ($amend) {
execx(
'(cd %s; git commit -a --amend -C HEAD)',
$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;