Skip to content

Commit aa0d039

Browse files
author
vrana
committed
Highlighting blame is broken if there is an unavailable commit
Test Plan: .../PhotoSnowlift.js?view=blame Reviewers: jungejason Reviewed By: jungejason CC: aran, epriestley Differential Revision: https://secure.phabricator.com/D2165
1 parent 7451c1f commit aa0d039

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

src/applications/diffusion/controller/file/DiffusionBrowseFileController.php

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ private function buildDisplayRows(
250250
$selected) {
251251

252252
if ($blame_dict) {
253-
$epoch_list = ipull($blame_dict, 'epoch');
253+
$epoch_list = ipull(ifilter($blame_dict, 'epoch'), 'epoch');
254254
$epoch_min = min($epoch_list);
255255
$epoch_max = max($epoch_list);
256256
$epoch_range = ($epoch_max - $epoch_min) + 1;
@@ -298,27 +298,30 @@ private function buildDisplayRows(
298298
} else {
299299
$blame = $blame_dict[$rev];
300300

301-
$color_ratio = ($blame['epoch'] - $epoch_min) / $epoch_range;
302-
303-
$color_value = 0xF6 * (1.0 - $color_ratio);
304-
$color = sprintf(
305-
'#%02x%02x%02x',
306-
$color_value,
307-
0xF6,
308-
$color_value);
301+
if (!isset($blame['epoch'])) {
302+
$color = '#ffd'; // Render as warning.
303+
} else {
304+
$color_ratio = ($blame['epoch'] - $epoch_min) / $epoch_range;
305+
$color_value = 0xF6 * (1.0 - $color_ratio);
306+
$color = sprintf(
307+
'#%02x%02x%02x',
308+
$color_value,
309+
0xF6,
310+
$color_value);
311+
}
309312

310-
$display_line['epoch'] = $blame['epoch'];
313+
$display_line['epoch'] = idx($blame, 'epoch');
311314
$display_line['color'] = $color;
312315
$display_line['commit'] = $rev;
313316

314-
if (isset($blame_dict[$rev]['handle'])) {
315-
$author_link = $blame_dict[$rev]['handle']->renderLink();
317+
if (isset($blame['handle'])) {
318+
$author_link = $blame['handle']->renderLink();
316319
} else {
317320
$author_link = phutil_render_tag(
318321
'span',
319322
array(
320323
),
321-
phutil_escape_html($blame_dict[$rev]['author']));
324+
phutil_escape_html($blame['author']));
322325
}
323326
$display_line['author'] = $author_link;
324327

src/applications/diffusion/query/filecontent/base/DiffusionFileContentQuery.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ final public function getBlameData() {
5959
list($rev_id, $author, $text) = $line;
6060
$rev_id = $rev_list[$k];
6161

62-
if (!isset($blame_dict[$rev_id]) &&
63-
!isset($blame_dict[$rev_id]['author'] )) {
62+
if (!isset($blame_dict[$rev_id])) {
6463
$blame_dict[$rev_id]['author'] = $author;
6564
}
6665
}

0 commit comments

Comments
 (0)