]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Make change amending explicit in arc lint
authorepriestley <epriestley@javelinjs.com>
Sun, 30 Jan 2011 01:18:32 +0000 (17:18 -0800)
committerepriestley <epriestley@javelinjs.com>
Sun, 30 Jan 2011 01:28:57 +0000 (17:28 -0800)
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
src/workflow/lint/ArcanistLintWorkflow.php

index 9bd5986375abef732cee8d01aa3a0090850fd716..fa0fe94ef095a8617a8bfe12f75127a7e191942e 100644 (file)
@@ -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:
index c031e68ceafb2b79c4442c9ed1c64eaaec869d04..ceb96b95666e38619e98312ebcbcaae8fdd2a4a6 100644 (file)
@@ -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(<<<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?");
       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.");
       }
     }