]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Fix a fatal for git uncommitted changes in new arc projects
authorepriestley <git@epriestley.com>
Wed, 5 Dec 2012 17:20:15 +0000 (09:20 -0800)
committerepriestley <git@epriestley.com>
Wed, 5 Dec 2012 17:20:15 +0000 (09:20 -0800)
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

index 0a468da380d843dbe2c43438b641b7ea04e9c2c0..86bf2eb7087bc1ff068859643010a814edeac22f 100644 (file)
@@ -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();
+        }
       }
     }