From 9a699f261a68a0639ccc7430384b2a7e144a612d Mon Sep 17 00:00:00 2001 From: epriestley Date: Sat, 29 Jan 2011 17:18:32 -0800 Subject: [PATCH] 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 --- src/workflow/diff/ArcanistDiffWorkflow.php | 9 ++++++--- src/workflow/lint/ArcanistLintWorkflow.php | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/workflow/diff/ArcanistDiffWorkflow.php b/src/workflow/diff/ArcanistDiffWorkflow.php index 9bd59863..fa0fe94e 100644 --- a/src/workflow/diff/ArcanistDiffWorkflow.php +++ b/src/workflow/diff/ArcanistDiffWorkflow.php @@ -56,7 +56,7 @@ EOTEXT public function requiresRepositoryAPI() { return true; } - + public function getDiffID() { return $this->diffID; } @@ -345,7 +345,7 @@ EOTEXT foreach ($changes as $change) { echo ' '.$change->renderTextSummary()."\n"; } - + $this->diffID = $diff_info['diffid']; return 0; @@ -855,7 +855,10 @@ EOTEXT $argv[] = $repository_api->getRelativeCommit(); } $lint_workflow = $this->buildChildWorkflow('lint', $argv); - $lint_result = $lint_workflow->run(); + + $lint_workflow->setShouldAmendChanges(true); + + $lint_result = $lint_workflow->run(); switch ($lint_result) { case ArcanistLintWorkflow::RESULT_OKAY: diff --git a/src/workflow/lint/ArcanistLintWorkflow.php b/src/workflow/lint/ArcanistLintWorkflow.php index c031e68c..ceb96b95 100644 --- a/src/workflow/lint/ArcanistLintWorkflow.php +++ b/src/workflow/lint/ArcanistLintWorkflow.php @@ -24,6 +24,12 @@ class ArcanistLintWorkflow extends ArcanistBaseWorkflow { const RESULT_SKIP = 3; private $unresolvedMessages; + private $shouldAmendChanges = false; + + public function setShouldAmendChanges($should_amend) { + $this->shouldAmendChanges = $should_amend; + return $this; + } public function getCommandHelp() { return phutil_console_format(<<shouldAmendChanges) { $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."); - } + throw new ArcanistUsageException( + "Sort out the lint changes that were applied to the working ". + "copy and relint."); } }