1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-19 13:22:42 +01:00

Only show text encoding note in Differential if a change has hunks

Summary: Fixes T5503. We incorrectly render an encoding note for empty files. Only render an encoding note for text changes with at least one hunk.

Test Plan:
  - Viewed empty file, no note.
  - Viewed nonempty file with altered encoding, saw note.

Reviewers: btrahan, joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Maniphest Tasks: T5503

Differential Revision: https://secure.phabricator.com/D9780
This commit is contained in:
epriestley 2014-06-29 12:42:59 -07:00
parent 2ac37c6964
commit c1af499ed7

View file

@ -252,15 +252,22 @@ abstract class DifferentialChangesetHTMLRenderer
break;
}
$encoding = $this->getOriginalCharacterEncoding();
if ($encoding != 'utf8' && ($file == DifferentialChangeType::FILE_TEXT)) {
if ($encoding) {
$messages[] = pht(
'This file was converted from %s for display.',
phutil_tag('strong', array(), $encoding));
} else {
$messages[] = pht(
'This file uses an unknown character encoding.');
// If this is a text file with at least one hunk, we may have converted
// the text encoding. In this case, show a note.
$show_encoding = ($file == DifferentialChangeType::FILE_TEXT) &&
($changeset->getHunks());
if ($show_encoding) {
$encoding = $this->getOriginalCharacterEncoding();
if ($encoding != 'utf8') {
if ($encoding) {
$messages[] = pht(
'This file was converted from %s for display.',
phutil_tag('strong', array(), $encoding));
} else {
$messages[] = pht(
'This file uses an unknown character encoding.');
}
}
}