]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Add --everything support to 'arc lint'
authorEric Stern <firehed@gmail.com>
Sun, 28 Jul 2013 01:29:20 +0000 (18:29 -0700)
committerepriestley <git@epriestley.com>
Sun, 28 Jul 2013 01:29:20 +0000 (18:29 -0700)
Summary:
When adding arcanist support to a new project or adding a new linter,
it's helpful to be able to run new linters against the entire codebase. This
patch adds support for this with an '--everything' option, similar to 'arc unit
--everything'

Test Plan:
Run 'arc lint --everything' and check out the code. Optionally dump
the paths to test in the current lint engine's buildLinters() function to
demonstrate that it's receiving all files in the project rather than just the
changed and/or specified ones

Reviewers: epriestley

Reviewed By: epriestley

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

src/workflow/ArcanistLintWorkflow.php

index 218d89be3f2c968f26ea1f7a5c7dc29e53aeec39..fb94a699e002aeb3136106894b0f07112d55ddae 100644 (file)
@@ -118,6 +118,13 @@ EOTEXT
           'When linting git repositories, amend HEAD with autofix '.
           'patches suggested by lint without prompting.',
       ),
+      'everything' => array(
+        'help' => 'Lint all files in the project.',
+        'conflicts' => array(
+          'cache' => '--everything lints all files',
+          'rev' => '--everything lints all files'
+        ),
+      ),
       'severity' => array(
         'param' => 'string',
         'help' =>
@@ -175,6 +182,12 @@ EOTEXT
     $rev = $this->getArgument('rev');
     $paths = $this->getArgument('paths');
     $use_cache = $this->getArgument('cache', null);
+    $everything = $this->getArgument('everything');
+    if ($everything && $paths) {
+      throw new ArcanistUsageException(
+        "You can not specify paths with --everything. The --everything ".
+        "flag lints every file.");
+    }
     if ($use_cache === null) {
       $use_cache = (bool)$working_copy->getConfigFromAnySource(
         'arc.lint.cache',
@@ -193,7 +206,25 @@ EOTEXT
       $this->shouldLintAll = true;
     }
 
-    $paths = $this->selectPathsForWorkflow($paths, $rev);
+    if ($everything) {
+      // Recurse through project from root
+      switch ($this->getRepositoryApi()->getSourceControlSystemName()) {
+        case 'git':
+          $filter = '*/.git';
+          break;
+        case 'svn':
+          $filter = '*/.svn';
+          break;
+        case 'hg':
+          $filter = '*/.hg';
+          break;
+      }
+      $paths = id(new FileFinder($working_copy->getProjectRoot()))
+        ->excludePath($filter)
+        ->find();
+    } else {
+      $paths = $this->selectPathsForWorkflow($paths, $rev);
+    }
 
     if (!class_exists($engine) ||
         !is_subclass_of($engine, 'ArcanistLintEngine')) {