From 44842aeb25f5b985df3bec5dbb13936a9e2572b8 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 30 Oct 2012 10:44:49 -0700 Subject: [PATCH] Don't try to run didAbortWorkflow() if the user never provided a command Summary: If you type `arc`, you currently get a fatal since $config isn't defined. Don't try to run the hook if we never built a config. (We could build the config earlier and then run the hook anyway, but $workflow and $command would not be defined. It seems unlikely that executing the hook here is useful, since it affects only the case that the user types `arc` on its own.) Test Plan: Typed `arc`. Typed `arc diff`, etc. Reviewers: vrana, btrahan Reviewed By: vrana CC: aran Differential Revision: https://secure.phabricator.com/D3841 --- scripts/arcanist.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/arcanist.php b/scripts/arcanist.php index 64938ede..d51baaac 100755 --- a/scripts/arcanist.php +++ b/scripts/arcanist.php @@ -63,6 +63,7 @@ $args = array_values($argv); $working_directory = getcwd(); $console = PhutilConsole::getConsole(); +$config = null; try { @@ -125,9 +126,9 @@ try { $user_config = ArcanistBaseWorkflow::readUserConfigurationFile(); - $config = $working_copy->getConfig('arcanist_configuration'); - if ($config) { - $config = new $config(); + $config_class = $working_copy->getConfig('arcanist_configuration'); + if ($config_class) { + $config = new $config_class(); } else { $config = new ArcanistConfiguration(); } @@ -327,7 +328,9 @@ try { $ex->getMessage()); } - $config->didAbortWorkflow($command, $workflow, $ex); + if ($config) { + $config->didAbortWorkflow($command, $workflow, $ex); + } if ($config_trace_mode) { echo "\n";