1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-25 15:00:58 +01:00

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
This commit is contained in:
Jason Ge 2011-07-01 19:02:27 -07:00
parent af107cff65
commit cd47271cf5

View file

@ -210,6 +210,9 @@ class PhabricatorObjectHandleData {
$repository = $repositories[$repository_ids[$phid]]; $repository = $repositories[$repository_ids[$phid]];
$commit_identifier = $commit->getCommitIdentifier(); $commit_identifier = $commit->getCommitIdentifier();
// 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(); $vcs = $repository->getVersionControlSystem();
if ($vcs == PhabricatorRepositoryType::REPOSITORY_TYPE_GIT) { if ($vcs == PhabricatorRepositoryType::REPOSITORY_TYPE_GIT) {
$short_identifier = substr($commit_identifier, 0, 16); $short_identifier = substr($commit_identifier, 0, 16);
@ -218,6 +221,11 @@ class PhabricatorObjectHandleData {
} }
$handle->setName('r'.$callsign.$short_identifier); $handle->setName('r'.$callsign.$short_identifier);
} else {
$handle->setName('Commit '.'r'.$callsign.$commit_identifier);
}
$handle->setURI('/r'.$callsign.$commit_identifier); $handle->setURI('/r'.$callsign.$commit_identifier);
$handle->setFullName('r'.$callsign.$commit_identifier); $handle->setFullName('r'.$callsign.$commit_identifier);
$handle->setTimestamp($commit->getEpoch()); $handle->setTimestamp($commit->getEpoch());