]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Support `arc lint --output none`
authorvrana <jakubv@fb.com>
Mon, 25 Feb 2013 20:33:51 +0000 (12:33 -0800)
committervrana <jakubv@fb.com>
Mon, 25 Feb 2013 22:55:57 +0000 (14:55 -0800)
Summary:
I want to run lint on background and I'm interested only in side effect of caching (and maybe exit status).
This is better than discarding stdout later because we don't do unnecessary work and error conditions are still printed.

Test Plan:
  $ arc lint --output none # with error
  $ echo $?
  $ arc lint --output none # with no lintable paths
  $ arc lint --output none # witout errors

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D5106

src/__phutil_library_map__.php
src/lint/linter/ArcanistPhutilXHPASTLinter.php
src/lint/renderer/ArcanistLintNoneRenderer.php [new file with mode: 0644]
src/workflow/ArcanistLintWorkflow.php

index 546cdac8686f58cb0db585c66628d4174fa37c89..9cf2a5115e308193ffc29737914400c06417443d 100644 (file)
@@ -84,6 +84,7 @@ phutil_register_library_map(array(
     'ArcanistLintJSONRenderer' => 'lint/renderer/ArcanistLintJSONRenderer.php',
     'ArcanistLintLikeCompilerRenderer' => 'lint/renderer/ArcanistLintLikeCompilerRenderer.php',
     'ArcanistLintMessage' => 'lint/ArcanistLintMessage.php',
+    'ArcanistLintNoneRenderer' => 'lint/renderer/ArcanistLintNoneRenderer.php',
     'ArcanistLintPatcher' => 'lint/ArcanistLintPatcher.php',
     'ArcanistLintRenderer' => 'lint/renderer/ArcanistLintRenderer.php',
     'ArcanistLintResult' => 'lint/ArcanistLintResult.php',
@@ -225,6 +226,7 @@ phutil_register_library_map(array(
     'ArcanistLintConsoleRenderer' => 'ArcanistLintRenderer',
     'ArcanistLintJSONRenderer' => 'ArcanistLintRenderer',
     'ArcanistLintLikeCompilerRenderer' => 'ArcanistLintRenderer',
+    'ArcanistLintNoneRenderer' => 'ArcanistLintRenderer',
     'ArcanistLintSummaryRenderer' => 'ArcanistLintRenderer',
     'ArcanistLintWorkflow' => 'ArcanistBaseWorkflow',
     'ArcanistLinterTestCase' => 'ArcanistPhutilTestCase',
index 4ae868e1b282850f200aa2d0193f6bdac963bf97..842e2b3552486e91e6ea2c508f6c95a0ec03d8db 100644 (file)
@@ -65,7 +65,12 @@ final class ArcanistPhutilXHPASTLinter extends ArcanistBaseXHPASTLinter {
   }
 
   public function getCacheVersion() {
-    return 2;
+    $version = '2';
+    $path = xhpast_get_binary_path();
+    if (Filesystem::pathExists($path)) {
+      $version .= '-'.md5_file($path);
+    }
+    return $version;
   }
 
   protected function buildFutures(array $paths) {
diff --git a/src/lint/renderer/ArcanistLintNoneRenderer.php b/src/lint/renderer/ArcanistLintNoneRenderer.php
new file mode 100644 (file)
index 0000000..da44ac8
--- /dev/null
@@ -0,0 +1,16 @@
+<?php
+
+/**
+ * @group lint
+ */
+final class ArcanistLintNoneRenderer extends ArcanistLintRenderer {
+
+  public function renderLintResult(ArcanistLintResult $result) {
+    return '';
+  }
+
+  public function renderOkayResult() {
+    return '';
+  }
+
+}
index 9ac3910d4042ca655147811133a55a7c2dfd5fad..8865e13b6c4eec497961b9b2d8d1c9ea847e3adc 100644 (file)
@@ -81,6 +81,7 @@ EOTEXT
         'help' =>
           "With 'summary', show lint warnings in a more compact format. ".
           "With 'json', show lint warnings in machine-readable JSON format. ".
+          "With 'none', show no lint warnings. ".
           "With 'compiler', show lint warnings in suitable for your editor."
       ),
       'only-new' => array(
@@ -384,6 +385,11 @@ EOTEXT
       case 'summary':
         $renderer = new ArcanistLintSummaryRenderer();
         break;
+      case 'none':
+        $prompt_patches = false;
+        $apply_patches = $this->getArgument('apply-patches');
+        $renderer = new ArcanistLintNoneRenderer();
+        break;
       case 'compiler':
         $renderer = new ArcanistLintLikeCompilerRenderer();
         $prompt_patches = false;
@@ -480,6 +486,11 @@ EOTEXT
     }
 
     if ($failed) {
+      if ($failed instanceof ArcanistNoEffectException) {
+        if ($renderer instanceof ArcanistLintNoneRenderer) {
+          return 0;
+        }
+      }
       throw $failed;
     }