]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Add --never-apply-patches and --apply-patches to lint.
authorepriestley <epriestley@javelinjs.com>
Mon, 10 Jan 2011 22:03:12 +0000 (14:03 -0800)
committerepriestley <epriestley@javelinjs.com>
Mon, 10 Jan 2011 22:04:51 +0000 (14:04 -0800)
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:

src/workflow/diff/ArcanistDiffWorkflow.php
src/workflow/lint/ArcanistLintWorkflow.php

index 17023a26111e9897f2f004b58f88655d6d4f1779..b9e1e15131275bbd094546f51fe8ec7b9272bd65 100644 (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 {
index e32d3426ee760dce1296be26779558742636067a..9b2d276e44a9da6a869eed77191273da1d1386e1 100644 (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;