1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-25 08:12:40 +01:00

Make change amending explicit in arc lint

Summary:
This should only happen on the 'diff' workflow.

Test Plan:
ran 'arc lint' and didn't get prompted to amend, ran 'arc diff' and got yelled
at for uncommitted changes, committed, ran 'arc diff' and got prompted to amend

Differential Revision: 206696
Reviewed By: adonohue
Reviewers: adonohue
CC: adonohue
Revert Plan:
OK
This commit is contained in:
epriestley 2011-01-29 17:18:32 -08:00
parent 100c55cf45
commit 9a699f261a
2 changed files with 18 additions and 9 deletions

View file

@ -855,7 +855,10 @@ EOTEXT
$argv[] = $repository_api->getRelativeCommit(); $argv[] = $repository_api->getRelativeCommit();
} }
$lint_workflow = $this->buildChildWorkflow('lint', $argv); $lint_workflow = $this->buildChildWorkflow('lint', $argv);
$lint_result = $lint_workflow->run();
$lint_workflow->setShouldAmendChanges(true);
$lint_result = $lint_workflow->run();
switch ($lint_result) { switch ($lint_result) {
case ArcanistLintWorkflow::RESULT_OKAY: case ArcanistLintWorkflow::RESULT_OKAY:

View file

@ -24,6 +24,12 @@ class ArcanistLintWorkflow extends ArcanistBaseWorkflow {
const RESULT_SKIP = 3; const RESULT_SKIP = 3;
private $unresolvedMessages; private $unresolvedMessages;
private $shouldAmendChanges = false;
public function setShouldAmendChanges($should_amend) {
$this->shouldAmendChanges = $should_amend;
return $this;
}
public function getCommandHelp() { public function getCommandHelp() {
return phutil_console_format(<<<EOTEXT return phutil_console_format(<<<EOTEXT
@ -213,18 +219,18 @@ EOTEXT
} }
} }
if ($wrote_to_disk && ($repository_api instanceof ArcanistGitAPI)) { if ($wrote_to_disk &&
($repository_api instanceof ArcanistGitAPI) &&
$this->shouldAmendChanges) {
$amend = phutil_console_confirm("Amend HEAD with lint patches?"); $amend = phutil_console_confirm("Amend HEAD with lint patches?");
if ($amend) { if ($amend) {
execx( execx(
'(cd %s; git commit -a --amend -C HEAD)', '(cd %s; git commit -a --amend -C HEAD)',
$repository_api->getPath()); $repository_api->getPath());
} else { } else {
if ($this->getParentWorkflow()) { throw new ArcanistUsageException(
throw new ArcanistUsageException( "Sort out the lint changes that were applied to the working ".
"Sort out the lint changes that were applied to the working ". "copy and relint.");
"copy and relint.");
}
} }
} }