]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Add a check to 'arc liberate' for loose .php files in the library root
authorepriestley <git@epriestley.com>
Tue, 13 Mar 2012 18:17:28 +0000 (11:17 -0700)
committerepriestley <git@epriestley.com>
Tue, 13 Mar 2012 18:17:28 +0000 (11:17 -0700)
Summary: @koolvin ran into this and was justifiably confused.

Test Plan: Put some random .php file in src/, ran arc liberate src/, got warned.

Reviewers: btrahan, Koolvin

Reviewed By: btrahan

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

src/workflow/liberate/ArcanistLiberateWorkflow.php

index 934b073a30e16aeb4bd3c21459321963cebf8ac2..03bf4601a6585696656a663b685969c2c72bf216 100644 (file)
@@ -131,6 +131,8 @@ EOTEXT
     $readable = Filesystem::readablePath($path);
     echo "Using library root at '{$readable}'...\n";
 
+    $this->checkForLooseFiles($path);
+
     if ($this->getArgument('all')) {
       echo "Dropping module cache...\n";
       Filesystem::remove($path.'/.phutil_module_cache');
@@ -339,4 +341,25 @@ EOTEXT
     return (int)$unresolved;
   }
 
+  /**
+   * Sanity check to catch people putting class files in the root of a libphutil
+   * library.
+   */
+  private function checkForLooseFiles($path) {
+    foreach (Filesystem::listDirectory($path) as $item) {
+      if (!preg_match('/\.php$/', $item)) {
+        // Not a ".php" file.
+        continue;
+      }
+      if (preg_match('/^__/', $item)) {
+        // Has magic '__' prefix.
+        continue;
+      }
+
+      echo phutil_console_wrap(
+        "WARNING: File '{$item}' is not in a module and won't be loaded. ".
+        "Put source files in subdirectories, not the top level directory.\n");
+    }
+  }
+
 }