Page MenuHomePhabricator

Allow arc alias to read aliases from system configuration file
Closed, ResolvedPublic

Description

Problem:
In our organisation we have been using arcanist for a workflow similar to those with the 'Arcanist Workflows' wiki. We use central development server wherein multiple developers can have separate user homes, and the server has a central arcconfig file located at /etc/arcconfig. We also have a few arc aliases that we use, including the 'arc cleanup' as discussed in T3277 (we had similar issues with clearing the arc patches manually). We have multiple separate projects (mainly using git) that are not hosted in phabricator.

Although the server has an arcconfig file it appears that arc alias does not read from the system configuration source. The alias workflow does not appear to read from getConfigFromAllSources() as the override order for the getAliases() is different (user is higher than project). As there are separate projects, the projects do not have the same configuration source, and to date, each user has their own .arcrc file. This means that if we want to modify alias, or add a new alias it has to be added in multiple different config files, which can get out of sync.

We currently use the below patch to enable reading aliases from the system config, but this complicates upgrading arcanist for our update script, as we have not forked arcanist, and have to reapply patch after each upgrade, rebasing as needed.

Proposal:
Ideally arc alias would be permitted to read from the system configuration, to allow aliases to be defined within the arcconfig file.

Not sure how unusual it would be to define aliases centrally, or maybe there is easier way to address our issue. I would be happy to submit a diff, if the proposed change would be acceptable to the upstream.

Arcanist: fcc11b3a278199fa15b90692aba65f54fef5d7f7
Libphutil: f43291e99d36045bc459e5133454c0d8fd8768ea

diff --git a/src/workflow/ArcanistAliasWorkflow.php b/src/workflow/ArcanistAliasWorkflow.php
index 7fc9dfe..a307270 100644
--- a/src/workflow/ArcanistAliasWorkflow.php
+++ b/src/workflow/ArcanistAliasWorkflow.php
@@ -60,16 +60,23 @@ EOTEXT
   public static function getAliases(
     ArcanistConfigurationManager $configuration_manager) {

-    $working_copy_config_aliases =
+    $system_aliases = idx(
+      $configuration_manager->readSystemArcConfig(),
+      'aliases',
+      array());
+
+    $working_copy_aliases =
       $configuration_manager->getProjectConfig('aliases');
-    if (!$working_copy_config_aliases) {
-      $working_copy_config_aliases = array();
+    if (!$working_copy_aliases) {
+      $working_copy_aliases = array();
     }
-    $user_config_aliases = idx(
+
+    $user_aliases = idx(
       $configuration_manager->readUserConfigurationFile(),
       'aliases',
       array());
-    return $user_config_aliases + $working_copy_config_aliases;
+
+    return $user_aliases + $working_copy_aliases + $system_aliases;
   }

   private function writeAliases(array $aliases) {

Event Timeline

eadler added a project: Restricted Project.Mar 9 2016, 10:11 PM
eadler moved this task from Restricted Project Column to Restricted Project Column on the Restricted Project board.
eadler moved this task from Restricted Project Column to Restricted Project Column on the Restricted Project board.
eadler moved this task from Restricted Project Column to Restricted Project Column on the Restricted Project board.Apr 7 2016, 6:05 PM
eadler moved this task from Restricted Project Column to Restricted Project Column on the Restricted Project board.Apr 7 2016, 6:07 PM
eadler moved this task from Restricted Project Column to Restricted Project Column on the Restricted Project board.Jun 6 2016, 4:16 PM
epriestley triaged this task as Normal priority.
epriestley added a project: Prioritized.
eadler moved this task from Restricted Project Column to Restricted Project Column on the Restricted Project board.Jun 6 2016, 8:09 PM
epriestley moved this task from Backlog to Paused on the Prioritized board.

Well, I'll leave this open for confirmation/feedback/etc.

This took 0.5 hours.

Haven't seen issues; now accounted for.