From 9d0100bda78a59c76b30638e4cc58437db3ba4d6 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 14 Apr 2020 12:45:49 -0700 Subject: [PATCH] Only inject legacy Arcanist workflows into "help" if run from the context of an Arcanist runtime Summary: Ref T13490. This code is reachable from Phabricator binaries; only inject the legacy stuff if we're in an Arcanist stack. Test Plan: Ran `bin/conduit help` from `phabricator/`. Maniphest Tasks: T13490 Differential Revision: https://secure.phabricator.com/D21113 --- .../workflow/PhutilHelpArgumentWorkflow.php | 62 ++++++++++--------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/src/parser/argument/workflow/PhutilHelpArgumentWorkflow.php b/src/parser/argument/workflow/PhutilHelpArgumentWorkflow.php index 7e455fc7..7257f68f 100644 --- a/src/parser/argument/workflow/PhutilHelpArgumentWorkflow.php +++ b/src/parser/argument/workflow/PhutilHelpArgumentWorkflow.php @@ -40,42 +40,44 @@ EOHELP $with = $args->getArg('help-with-what'); $runtime = $this->getRuntime(); - $toolset = $runtime->getToolset(); - if ($toolset->getToolsetKey() === 'arc') { - $workflows = $args->getWorkflows(); + if ($runtime) { + $toolset = $runtime->getToolset(); + if ($toolset->getToolsetKey() === 'arc') { + $workflows = $args->getWorkflows(); - $legacy = array(); + $legacy = array(); - $legacy[] = new ArcanistCloseRevisionWorkflow(); - $legacy[] = new ArcanistCommitWorkflow(); - $legacy[] = new ArcanistCoverWorkflow(); - $legacy[] = new ArcanistDiffWorkflow(); - $legacy[] = new ArcanistExportWorkflow(); - $legacy[] = new ArcanistGetConfigWorkflow(); - $legacy[] = new ArcanistSetConfigWorkflow(); - $legacy[] = new ArcanistInstallCertificateWorkflow(); - $legacy[] = new ArcanistLandWorkflow(); - $legacy[] = new ArcanistLintersWorkflow(); - $legacy[] = new ArcanistLintWorkflow(); - $legacy[] = new ArcanistListWorkflow(); - $legacy[] = new ArcanistPatchWorkflow(); - $legacy[] = new ArcanistPasteWorkflow(); - $legacy[] = new ArcanistTasksWorkflow(); - $legacy[] = new ArcanistTodoWorkflow(); - $legacy[] = new ArcanistUnitWorkflow(); - $legacy[] = new ArcanistWhichWorkflow(); + $legacy[] = new ArcanistCloseRevisionWorkflow(); + $legacy[] = new ArcanistCommitWorkflow(); + $legacy[] = new ArcanistCoverWorkflow(); + $legacy[] = new ArcanistDiffWorkflow(); + $legacy[] = new ArcanistExportWorkflow(); + $legacy[] = new ArcanistGetConfigWorkflow(); + $legacy[] = new ArcanistSetConfigWorkflow(); + $legacy[] = new ArcanistInstallCertificateWorkflow(); + $legacy[] = new ArcanistLandWorkflow(); + $legacy[] = new ArcanistLintersWorkflow(); + $legacy[] = new ArcanistLintWorkflow(); + $legacy[] = new ArcanistListWorkflow(); + $legacy[] = new ArcanistPatchWorkflow(); + $legacy[] = new ArcanistPasteWorkflow(); + $legacy[] = new ArcanistTasksWorkflow(); + $legacy[] = new ArcanistTodoWorkflow(); + $legacy[] = new ArcanistUnitWorkflow(); + $legacy[] = new ArcanistWhichWorkflow(); - foreach ($legacy as $workflow) { - // If this workflow has been updated but not removed from the list - // above yet, just skip it. - if ($workflow instanceof ArcanistArcWorkflow) { - continue; + foreach ($legacy as $workflow) { + // If this workflow has been updated but not removed from the list + // above yet, just skip it. + if ($workflow instanceof ArcanistArcWorkflow) { + continue; + } + + $workflows[] = $workflow->newLegacyPhutilWorkflow(); } - $workflows[] = $workflow->newLegacyPhutilWorkflow(); + $args->setWorkflows($workflows); } - - $args->setWorkflows($workflows); } if (!$with) {