]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Make sure the local arc config directory exists on `ArcanistWorkingCopyIdentity:...
authorJoshua Spence <josh@joshuaspence.com>
Tue, 10 Dec 2013 21:29:19 +0000 (08:29 +1100)
committerepriestley <git@epriestley.com>
Wed, 11 Dec 2013 14:42:46 +0000 (06:42 -0800)
See: <https://github.com/facebook/arcanist/pull/126>

Reviewed by: epriestley

src/configuration/ArcanistConfigurationManager.php
src/workingcopyidentity/ArcanistWorkingCopyIdentity.php

index 79c5a756311968e73023ed9e09c97b29fdc598b6..bc22240cea1a62434b5c0491c56626604a004b2f 100644 (file)
@@ -145,7 +145,7 @@ final class ArcanistConfigurationManager {
       return $this->workingCopy->writeLocalArcConfig($config);
     }
 
-    return false;
+    throw new Exception(pht("No working copy to write config to!"));
   }
 
   /**
index 7c61715352a332bcdefa8f4eac8b62385d4eefe3..e94dec93d7da4c259c816de0e9090e716b63d2d2 100644 (file)
@@ -312,30 +312,21 @@ final class ArcanistWorkingCopyIdentity {
   }
 
   public function writeLocalArcConfig(array $config) {
+    $json_encoder = new PhutilJSON();
+    $json = $json_encoder->encodeFormatted($config);
+
     $dir = $this->localMetaDir;
     if (!strlen($dir)) {
-      return false;
+      throw new Exception(pht('No working copy to write config into!'));
     }
 
-    if (!Filesystem::pathExists($dir)) {
-      try {
-        Filesystem::createDirectory($dir);
-      } catch (Exception $ex) {
-        return false;
-      }
-    }
-
-    $json_encoder = new PhutilJSON();
-    $json = $json_encoder->encodeFormatted($config);
-
-    $config_file = Filesystem::resolvePath('arc/config', $dir);
-     try {
-      Filesystem::writeFile($config_file, $json);
-    } catch (FilesystemException $ex) {
-      return false;
+    $local_dir = $dir.DIRECTORY_SEPARATOR.'arc';
+    if (!Filesystem::pathExists($local_dir)) {
+      Filesystem::createDirectory($local_dir, 0755);
     }
 
-    return true;
+    $config_file = $local_dir.DIRECTORY_SEPARATOR.'config';
+    Filesystem::writeFile($config_file, $json);
   }
 
 }