Skip to content

Commit

Permalink
set custom arcrc file earlier
Browse files Browse the repository at this point in the history
Summary: It appears to have never really work? At least as far as phabricator.uri (empirically).

Test Plan:
removed ~/.arcrc, run call-conduit user.whoami with --arcrc-file and --trace.
set-config, get-config and alias also read and write to the right place now.

Reviewers: avivey

Reviewed By: avivey

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9263
  • Loading branch information
epriestley committed May 23, 2014
1 parent 1782044 commit 0d0b8ab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
6 changes: 3 additions & 3 deletions scripts/arcanist.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@
}

$configuration_manager = new ArcanistConfigurationManager();
if ($custom_arcrc) {
$configuration_manager->setUserConfigurationFileLocation($custom_arcrc);
}

$global_config = $configuration_manager->readUserArcConfig();
$system_config = $configuration_manager->readSystemArcConfig();
Expand Down Expand Up @@ -141,9 +144,6 @@
$working_copy);
}

if ($custom_arcrc) {
$configuration_manager->setUserConfigurationFileLocation($custom_arcrc);
}
$user_config = $configuration_manager->readUserConfigurationFile();

$config_class = $working_copy->getProjectConfig('arcanist_configuration');
Expand Down
23 changes: 12 additions & 11 deletions src/configuration/ArcanistConfigurationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ final class ArcanistConfigurationManager {
private $runtimeConfig = array();
private $workingCopy = null;
private $customArcrcFilename = null;
private $userConfigCache = null;

public function setWorkingCopyIdentity(
ArcanistWorkingCopyIdentity $working_copy) {
Expand Down Expand Up @@ -159,13 +160,11 @@ public function writeLocalArcConfig(array $config) {
* @{method:readUserArcConfig}.
*/
public function readUserConfigurationFile() {
static $user_config;
if ($user_config === null) {
if ($this->userConfigCache === null) {
$user_config = array();
$user_config_path = self::getUserConfigurationFileLocation();
$user_config_path = $this->getUserConfigurationFileLocation();

$console = PhutilConsole::getConsole();

if (Filesystem::pathExists($user_config_path)) {
$console->writeLog(
"%s\n",
Expand Down Expand Up @@ -212,8 +211,10 @@ public function readUserConfigurationFile() {
$user_config_path));
}

$this->userConfigCache = $user_config;
}
return $user_config;

return $this->userConfigCache;
}

/**
Expand All @@ -224,7 +225,7 @@ public function writeUserConfigurationFile($config) {
$json_encoder = new PhutilJSON();
$json = $json_encoder->encodeFormatted($config);

$path = self::getUserConfigurationFileLocation();
$path = $this->getUserConfigurationFileLocation();
Filesystem::writeFile($path, $json);

if (!phutil_is_windows()) {
Expand All @@ -239,6 +240,7 @@ public function setUserConfigurationFileLocation($custom_arcrc) {
}

$this->customArcrcFilename = $custom_arcrc;
$this->userConfigCache = null;
}

public function getUserConfigurationFileLocation() {
Expand All @@ -254,16 +256,15 @@ public function getUserConfigurationFileLocation() {
}

public function readUserArcConfig() {
return idx(self::readUserConfigurationFile(), 'config', array());
return idx($this->readUserConfigurationFile(), 'config', array());
}

public function writeUserArcConfig(array $options) {
$config = self::readUserConfigurationFile();
$config = $this->readUserConfigurationFile();
$config['config'] = $options;
self::writeUserConfigurationFile($config);
$this->writeUserConfigurationFile($config);
}


public function getSystemArcConfigLocation() {
if (phutil_is_windows()) {
return Filesystem::resolvePath(
Expand All @@ -278,7 +279,7 @@ public function readSystemArcConfig() {
static $system_config;
if ($system_config === null) {
$system_config = array();
$system_config_path = self::getSystemArcConfigLocation();
$system_config_path = $this->getSystemArcConfigLocation();

$console = PhutilConsole::getConsole();

Expand Down

0 comments on commit 0d0b8ab

Please sign in to comment.