1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-21 14:22:40 +01:00

set custom arcrc file earlier

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
This commit is contained in:
epriestley 2014-05-23 14:06:29 -07:00
parent 17820442da
commit 0d0b8abcdd
2 changed files with 15 additions and 14 deletions

View file

@ -80,6 +80,9 @@ try {
}
$configuration_manager = new ArcanistConfigurationManager();
if ($custom_arcrc) {
$configuration_manager->setUserConfigurationFileLocation($custom_arcrc);
}
$global_config = $configuration_manager->readUserArcConfig();
$system_config = $configuration_manager->readSystemArcConfig();
@ -141,9 +144,6 @@ try {
$working_copy);
}
if ($custom_arcrc) {
$configuration_manager->setUserConfigurationFileLocation($custom_arcrc);
}
$user_config = $configuration_manager->readUserConfigurationFile();
$config_class = $working_copy->getProjectConfig('arcanist_configuration');

View file

@ -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) {
@ -159,13 +160,11 @@ final class ArcanistConfigurationManager {
* @{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",
@ -212,8 +211,10 @@ final class ArcanistConfigurationManager {
$user_config_path));
}
$this->userConfigCache = $user_config;
}
return $user_config;
return $this->userConfigCache;
}
/**
@ -224,7 +225,7 @@ final class ArcanistConfigurationManager {
$json_encoder = new PhutilJSON();
$json = $json_encoder->encodeFormatted($config);
$path = self::getUserConfigurationFileLocation();
$path = $this->getUserConfigurationFileLocation();
Filesystem::writeFile($path, $json);
if (!phutil_is_windows()) {
@ -239,6 +240,7 @@ final class ArcanistConfigurationManager {
}
$this->customArcrcFilename = $custom_arcrc;
$this->userConfigCache = null;
}
public function getUserConfigurationFileLocation() {
@ -254,16 +256,15 @@ final class ArcanistConfigurationManager {
}
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(
@ -278,7 +279,7 @@ final class ArcanistConfigurationManager {
static $system_config;
if ($system_config === null) {
$system_config = array();
$system_config_path = self::getSystemArcConfigLocation();
$system_config_path = $this->getSystemArcConfigLocation();
$console = PhutilConsole::getConsole();