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