1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-21 22:32:41 +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(); $configuration_manager = new ArcanistConfigurationManager();
if ($custom_arcrc) {
$configuration_manager->setUserConfigurationFileLocation($custom_arcrc);
}
$global_config = $configuration_manager->readUserArcConfig(); $global_config = $configuration_manager->readUserArcConfig();
$system_config = $configuration_manager->readSystemArcConfig(); $system_config = $configuration_manager->readSystemArcConfig();
@ -141,9 +144,6 @@ try {
$working_copy); $working_copy);
} }
if ($custom_arcrc) {
$configuration_manager->setUserConfigurationFileLocation($custom_arcrc);
}
$user_config = $configuration_manager->readUserConfigurationFile(); $user_config = $configuration_manager->readUserConfigurationFile();
$config_class = $working_copy->getProjectConfig('arcanist_configuration'); $config_class = $working_copy->getProjectConfig('arcanist_configuration');

View file

@ -10,6 +10,7 @@ final class ArcanistConfigurationManager {
private $runtimeConfig = array(); private $runtimeConfig = array();
private $workingCopy = null; private $workingCopy = null;
private $customArcrcFilename = null; private $customArcrcFilename = null;
private $userConfigCache = null;
public function setWorkingCopyIdentity( public function setWorkingCopyIdentity(
ArcanistWorkingCopyIdentity $working_copy) { ArcanistWorkingCopyIdentity $working_copy) {
@ -159,13 +160,11 @@ final class ArcanistConfigurationManager {
* @{method:readUserArcConfig}. * @{method:readUserArcConfig}.
*/ */
public function readUserConfigurationFile() { public function readUserConfigurationFile() {
static $user_config; if ($this->userConfigCache === null) {
if ($user_config === null) {
$user_config = array(); $user_config = array();
$user_config_path = self::getUserConfigurationFileLocation(); $user_config_path = $this->getUserConfigurationFileLocation();
$console = PhutilConsole::getConsole(); $console = PhutilConsole::getConsole();
if (Filesystem::pathExists($user_config_path)) { if (Filesystem::pathExists($user_config_path)) {
$console->writeLog( $console->writeLog(
"%s\n", "%s\n",
@ -212,8 +211,10 @@ final class ArcanistConfigurationManager {
$user_config_path)); $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_encoder = new PhutilJSON();
$json = $json_encoder->encodeFormatted($config); $json = $json_encoder->encodeFormatted($config);
$path = self::getUserConfigurationFileLocation(); $path = $this->getUserConfigurationFileLocation();
Filesystem::writeFile($path, $json); Filesystem::writeFile($path, $json);
if (!phutil_is_windows()) { if (!phutil_is_windows()) {
@ -239,6 +240,7 @@ final class ArcanistConfigurationManager {
} }
$this->customArcrcFilename = $custom_arcrc; $this->customArcrcFilename = $custom_arcrc;
$this->userConfigCache = null;
} }
public function getUserConfigurationFileLocation() { public function getUserConfigurationFileLocation() {
@ -254,16 +256,15 @@ final class ArcanistConfigurationManager {
} }
public function readUserArcConfig() { public function readUserArcConfig() {
return idx(self::readUserConfigurationFile(), 'config', array()); return idx($this->readUserConfigurationFile(), 'config', array());
} }
public function writeUserArcConfig(array $options) { public function writeUserArcConfig(array $options) {
$config = self::readUserConfigurationFile(); $config = $this->readUserConfigurationFile();
$config['config'] = $options; $config['config'] = $options;
self::writeUserConfigurationFile($config); $this->writeUserConfigurationFile($config);
} }
public function getSystemArcConfigLocation() { public function getSystemArcConfigLocation() {
if (phutil_is_windows()) { if (phutil_is_windows()) {
return Filesystem::resolvePath( return Filesystem::resolvePath(
@ -278,7 +279,7 @@ final class ArcanistConfigurationManager {
static $system_config; static $system_config;
if ($system_config === null) { if ($system_config === null) {
$system_config = array(); $system_config = array();
$system_config_path = self::getSystemArcConfigLocation(); $system_config_path = $this->getSystemArcConfigLocation();
$console = PhutilConsole::getConsole(); $console = PhutilConsole::getConsole();