From ba1a17ac31458f46c4e1530df7236667107f0d3a Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 5 Dec 2012 09:20:15 -0800 Subject: [PATCH] Fix a fatal for git uncommitted changes in new arc projects Summary: If you run `arc diff` in a repository which: - has uncommitted or untracked changes; and - has a .arcconfig with a never-before-seen project ID; - we fatal: http://pastebin.com/raw.php?i=ykpfr4MT This patch is a bit iffy, open to alternatives. The "right" patch is probably an `arcanistproject.query` which behaves more sensibly. I return array() directly since we'll later create the project. Test Plan: Ran `arc diff` in a repository with untracked files or uncommitted changes and a new project ID. Reviewers: vrana Reviewed By: vrana CC: aran Differential Revision: https://secure.phabricator.com/D4057 --- src/workflow/ArcanistBaseWorkflow.php | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/workflow/ArcanistBaseWorkflow.php b/src/workflow/ArcanistBaseWorkflow.php index 0a468da3..86bf2eb7 100644 --- a/src/workflow/ArcanistBaseWorkflow.php +++ b/src/workflow/ArcanistBaseWorkflow.php @@ -1408,11 +1408,24 @@ abstract class ArcanistBaseWorkflow { if (!$project_id) { $this->projectInfo = array(); } else { - $this->projectInfo = $this->getConduit()->callMethodSynchronous( - 'arcanist.projectinfo', - array( - 'name' => $project_id, - )); + try { + $this->projectInfo = $this->getConduit()->callMethodSynchronous( + 'arcanist.projectinfo', + array( + 'name' => $project_id, + )); + } catch (ConduitClientException $ex) { + if ($ex->getErrorCode() != 'ERR-BAD-ARCANIST-PROJECT') { + throw $ex; + } + + // TODO: Implement a proper query method that doesn't throw on + // project not found. We just swallow this because some pathways, + // like Git with uncommitted changes in a repository with a new + // project ID, may attempt to access project information before + // the project is created. See T2153. + return array(); + } } }