]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Support "load" key in arc system configuration
authorepriestley <git@epriestley.com>
Fri, 6 Jul 2012 17:05:55 +0000 (10:05 -0700)
committerepriestley <git@epriestley.com>
Fri, 6 Jul 2012 17:05:55 +0000 (10:05 -0700)
Summary: I think @nh needs this at some point?

Test Plan: Added bogus and valid "load" to system config, got warning and load respectively.

Reviewers: nh, dschleimer, btrahan

Reviewed By: dschleimer

CC: aran
Differential Revision: https://secure.phabricator.com/D2931

scripts/arcanist.php

index dfc9e01dc54bc5dfc85db4e781a09e42ceec65df..8784b903259b1d26ccd0b3e0f5d6dc7471f721a4 100755 (executable)
@@ -78,6 +78,7 @@ try {
   }
 
   $global_config = ArcanistBaseWorkflow::readGlobalArcConfig();
+  $system_config = ArcanistBaseWorkflow::readSystemArcConfig();
   $working_copy = ArcanistWorkingCopyIdentity::newFromPath($working_directory);
 
   // Load additional libraries, which can provide new classes like configuration
@@ -97,6 +98,16 @@ try {
       $working_copy,
       $config_trace_mode);
   } else {
+    // Load libraries in system 'load' config. In contrast to global config, we
+    // fail hard here because this file is edited manually, so if 'arc' breaks
+    // that doesn't make it any more difficult to correct.
+    arcanist_load_libraries(
+      idx($system_config, 'load', array()),
+      $must_load = true,
+      $lib_source = 'the "load" setting in system config',
+      $working_copy,
+      $config_trace_mode);
+
     // Load libraries in global 'load' config, as per "arc set-config load". We
     // need to fail softly if these break because errors would prevent the user
     // from running "arc set-config" to correct them.
@@ -435,6 +446,14 @@ function arcanist_load_libraries(
     return;
   }
 
+  if (!is_array($load)) {
+    $error = "Libraries specified by {$lib_source} are invalid; expected ".
+             "a list. Check your configuration.";
+    $console = PhutilConsole::getConsole();
+    $console->writeErr("WARNING: %s\n", $error);
+    return;
+  }
+
   foreach ($load as $location) {
 
     // Try to resolve the library location. We look in several places, in