From cd47271cf5e7a5fe3b94d0ed994e5f7b90e76d46 Mon Sep 17 00:00:00 2001 From: Jason Ge Date: Fri, 1 Jul 2011 19:02:27 -0700 Subject: [PATCH] Handle the case when a repository was deleted Summary: when a repository was deleted, PhabricatorObjectHandleData::loadHandles() is throwing exception because it assumes that the repository for the commit exists. Test Plan: try an revision whose repo was deleted and it renders. Reviewed By: epriestley Reviewers: epriestley, andrewjcg CC: aran, epriestley Differential Revision: 576 --- .../data/PhabricatorObjectHandleData.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/applications/phid/handle/data/PhabricatorObjectHandleData.php b/src/applications/phid/handle/data/PhabricatorObjectHandleData.php index 9e1f4c9c65..06b99cccb3 100644 --- a/src/applications/phid/handle/data/PhabricatorObjectHandleData.php +++ b/src/applications/phid/handle/data/PhabricatorObjectHandleData.php @@ -210,14 +210,22 @@ class PhabricatorObjectHandleData { $repository = $repositories[$repository_ids[$phid]]; $commit_identifier = $commit->getCommitIdentifier(); - $vcs = $repository->getVersionControlSystem(); - if ($vcs == PhabricatorRepositoryType::REPOSITORY_TYPE_GIT) { - $short_identifier = substr($commit_identifier, 0, 16); + // In case where the repository for the commit was deleted, + // we don't have have info about the repository anymore. + if ($repository) { + $vcs = $repository->getVersionControlSystem(); + if ($vcs == PhabricatorRepositoryType::REPOSITORY_TYPE_GIT) { + $short_identifier = substr($commit_identifier, 0, 16); + } else { + $short_identifier = $commit_identifier; + } + + $handle->setName('r'.$callsign.$short_identifier); } else { - $short_identifier = $commit_identifier; + + $handle->setName('Commit '.'r'.$callsign.$commit_identifier); } - $handle->setName('r'.$callsign.$short_identifier); $handle->setURI('/r'.$callsign.$commit_identifier); $handle->setFullName('r'.$callsign.$commit_identifier); $handle->setTimestamp($commit->getEpoch());