1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Fix a fatal in the document engine blame view with files that blame to the initial commit

Summary:
Ref T13126. When you view a file using the new document engine view and some lines were introduced in the initial commit to the repository, Git renders "^abc123" in the blame output.

We currently don't do anything about this, and later fail to look it up and fatal.

It's also unlikely-but-conceivably-possible to end up here if a commit has not imported yet or has been nuked with `bin/remove destroy`.

Let the whole thing run without fataling even if a `$commit` is missing. Future refinements could improve this behavior.

Test Plan: Viewed a file with lines introduced in the initial commit, got empty blame instead of a fatal.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13126

Differential Revision: https://secure.phabricator.com/D19391
This commit is contained in:
epriestley 2018-04-20 12:51:31 -07:00
parent 9bf4df2c1d
commit 95e179d9a4

View file

@ -80,7 +80,6 @@ final class DiffusionBlameController extends DiffusionController {
$handles = $viewer->loadHandles($handle_phids);
$map = array();
$epochs = array();
foreach ($identifiers as $identifier) {
@ -106,9 +105,21 @@ final class DiffusionBlameController extends DiffusionController {
),
$skip_icon);
$commit = $commits[$identifier];
// We may not have a commit object for a given identifier if the commit
// has not imported yet.
// At time of writing, this can also happen if a line was part of the
// initial import: blame produces a "^abc123" identifier in Git, which
// doesn't correspond to a real commit.
$commit = idx($commits, $identifier);
$author_phid = null;
if ($commit) {
$author_phid = $commit->getAuthorPHID();
}
if (!$author_phid && $revision) {
$author_phid = $revision->getAuthorPHID();
}
@ -141,6 +152,7 @@ final class DiffusionBlameController extends DiffusionController {
'meta' => $author_meta,
));
if ($commit) {
$commit_link = javelin_tag(
'a',
array(
@ -153,6 +165,9 @@ final class DiffusionBlameController extends DiffusionController {
),
),
$commit->getLocalName());
} else {
$commit_link = null;
}
$info = array(
$author_link,
@ -180,7 +195,12 @@ final class DiffusionBlameController extends DiffusionController {
);
}
if ($commit) {
$epoch = $commit->getEpoch();
} else {
$epoch = 0;
}
$epochs[] = $epoch;
$data = array(