mirror of
https://we.phorge.it/source/arcanist.git
synced 2025-01-25 22:18:18 +01:00
[arcanist] add system arc config file
Summary: Adds a system arc config file with precedence below the user config file, both to ArcanistWorkingCopyIdentity::readConfigFromAnySource() and to base commit resolution. Test Plan: [14:48:45 Mon Jun 25 2012] dschleimer@dev4022.snc6 ~/devtools/arcanist arcanist system_config 21245 $ cat /etc/arcconfig { "base": "literal:foobar" } [14:52:31 Mon Jun 25 2012] dschleimer@dev4022.snc6 ~/devtools/arcanist arcanist system_config 21246 $ ./bin/arc get-config base (system) base = literal:foobar (global) base = [14:52:39 Mon Jun 25 2012] dschleimer@dev4022.snc6 ~/devtools/arcanist arcanist system_config 21247 $ ./bin/arc which --show-base --base 'arc:system' foobar Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T1233 Differential Revision: https://secure.phabricator.com/D2854
This commit is contained in:
parent
e1371493be
commit
82d05fee9f
5 changed files with 39 additions and 1 deletions
|
@ -58,6 +58,7 @@ final class ArcanistBaseCommitParser {
|
||||||
'local' => '',
|
'local' => '',
|
||||||
'project' => '',
|
'project' => '',
|
||||||
'global' => '',
|
'global' => '',
|
||||||
|
'system' => '',
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($specs as $source => $spec) {
|
foreach ($specs as $source => $spec) {
|
||||||
|
@ -69,6 +70,7 @@ final class ArcanistBaseCommitParser {
|
||||||
'local',
|
'local',
|
||||||
'project',
|
'project',
|
||||||
'global',
|
'global',
|
||||||
|
'system',
|
||||||
);
|
);
|
||||||
|
|
||||||
while ($this->try) {
|
while ($this->try) {
|
||||||
|
@ -143,6 +145,7 @@ final class ArcanistBaseCommitParser {
|
||||||
case 'global':
|
case 'global':
|
||||||
case 'project':
|
case 'project':
|
||||||
case 'args':
|
case 'args':
|
||||||
|
case 'system':
|
||||||
// Push the other source on top of the list.
|
// Push the other source on top of the list.
|
||||||
array_unshift($this->try, $name);
|
array_unshift($this->try, $name);
|
||||||
$this->log("Switching to source '{$name}'.");
|
$this->log("Switching to source '{$name}'.");
|
||||||
|
|
|
@ -409,6 +409,7 @@ abstract class ArcanistRepositoryAPI {
|
||||||
public function resolveBaseCommit() {
|
public function resolveBaseCommit() {
|
||||||
$working_copy = $this->getWorkingCopyIdentity();
|
$working_copy = $this->getWorkingCopyIdentity();
|
||||||
$global_config = ArcanistBaseWorkflow::readGlobalArcConfig();
|
$global_config = ArcanistBaseWorkflow::readGlobalArcConfig();
|
||||||
|
$system_config = ArcanistBaseWorkflow::readSystemArcConfig();
|
||||||
|
|
||||||
$parser = new ArcanistBaseCommitParser($this);
|
$parser = new ArcanistBaseCommitParser($this);
|
||||||
$commit = $parser->resolveBaseCommit(
|
$commit = $parser->resolveBaseCommit(
|
||||||
|
@ -417,6 +418,7 @@ abstract class ArcanistRepositoryAPI {
|
||||||
'local' => $working_copy->getLocalConfig('base', ''),
|
'local' => $working_copy->getLocalConfig('base', ''),
|
||||||
'project' => $working_copy->getConfig('base', ''),
|
'project' => $working_copy->getConfig('base', ''),
|
||||||
'global' => idx($global_config, 'base', ''),
|
'global' => idx($global_config, 'base', ''),
|
||||||
|
'system' => idx($system_config, 'base', ''),
|
||||||
));
|
));
|
||||||
|
|
||||||
return $commit;
|
return $commit;
|
||||||
|
|
|
@ -965,6 +965,29 @@ abstract class ArcanistBaseWorkflow {
|
||||||
return $argv;
|
return $argv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getSystemArcConfigLocation() {
|
||||||
|
if (phutil_is_windows()) {
|
||||||
|
// this is a horrible place to put this, but there doesn't seem to be a
|
||||||
|
// non-horrible place on Windows
|
||||||
|
return Filesystem::resolvePath(
|
||||||
|
'Phabricator/Arcanist/config',
|
||||||
|
getenv('PROGRAMFILES'));
|
||||||
|
} else {
|
||||||
|
return '/etc/arcconfig';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function readSystemArcConfig() {
|
||||||
|
$system_config = array();
|
||||||
|
$system_config_path = self::getSystemArcConfigLocation();
|
||||||
|
if (Filesystem::pathExists($system_config_path)) {
|
||||||
|
$file = Filesystem::readFile($system_config_path);
|
||||||
|
if ($file) {
|
||||||
|
$system_config = json_decode($file, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $system_config;
|
||||||
|
}
|
||||||
public static function getUserConfigurationFileLocation() {
|
public static function getUserConfigurationFileLocation() {
|
||||||
if (phutil_is_windows()) {
|
if (phutil_is_windows()) {
|
||||||
return getenv('APPDATA').'/.arcrc';
|
return getenv('APPDATA').'/.arcrc';
|
||||||
|
|
|
@ -53,6 +53,7 @@ EOTEXT
|
||||||
$argv = $this->getArgument('argv');
|
$argv = $this->getArgument('argv');
|
||||||
|
|
||||||
$configs = array(
|
$configs = array(
|
||||||
|
'system' => self::readSystemArcConfig(),
|
||||||
'global' => self::readGlobalArcConfig(),
|
'global' => self::readGlobalArcConfig(),
|
||||||
'local' => $this->readLocalArcConfig(),
|
'local' => $this->readLocalArcConfig(),
|
||||||
);
|
);
|
||||||
|
|
|
@ -202,7 +202,16 @@ final class ArcanistWorkingCopyIdentity {
|
||||||
// lastly, try global (i.e. user-level) config
|
// lastly, try global (i.e. user-level) config
|
||||||
if ($pval === null) {
|
if ($pval === null) {
|
||||||
$global_config = ArcanistBaseWorkflow::readGlobalArcConfig();
|
$global_config = ArcanistBaseWorkflow::readGlobalArcConfig();
|
||||||
$pval = idx($global_config, $key, $default);
|
$pval = idx($global_config, $key);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($pval === null) {
|
||||||
|
$system_config = ArcanistBaseWorkflow::readSystemArcConfig();
|
||||||
|
$pval = idx($system_config, $key);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($pval === null) {
|
||||||
|
$pval = $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $pval;
|
return $pval;
|
||||||
|
|
Loading…
Add table
Reference in a new issue