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

phutil_utf8_shorten => PhutilUTF8StringTruncator

Summary: Ref T3307. Very easy

Test Plan: this very diff!

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T3307

Differential Revision: https://secure.phabricator.com/D10391
This commit is contained in:
Bob Trahan 2014-08-29 15:15:18 -07:00
parent f17b1fa1c4
commit c8f15136c8
3 changed files with 12 additions and 3 deletions

View file

@ -24,7 +24,9 @@ final class ArcanistXUnitTestResultParser {
$load_success = @$xunit_dom->loadXML($test_results); $load_success = @$xunit_dom->loadXML($test_results);
if (!$load_success) { if (!$load_success) {
$input_start = phutil_utf8_shorten($test_results, 150); $input_start = id(new PhutilUTF8StringTruncator())
->setMaximumGlyphs(150)
->truncateString($test_results);
throw new Exception( throw new Exception(
"Failed to load XUnit report; Input starts with:\n\n {$input_start}"); "Failed to load XUnit report; Input starts with:\n\n {$input_start}");
} }

View file

@ -1509,7 +1509,9 @@ EOTEXT
$preview = explode("\n", $saved); $preview = explode("\n", $saved);
$preview = array_shift($preview); $preview = array_shift($preview);
$preview = trim($preview); $preview = trim($preview);
$preview = phutil_utf8_shorten($preview, 64); $preview = id(new PhutilUTF8StringTruncator())
->setMaximumGlyphs(64)
->truncateString($preview);
if ($preview) { if ($preview) {
$preview = "Message begins:\n\n {$preview}\n\n"; $preview = "Message begins:\n\n {$preview}\n\n";

View file

@ -88,7 +88,12 @@ EOTEXT
// Make sure notes that are long or have line breaks in them or // Make sure notes that are long or have line breaks in them or
// whatever don't mess up the formatting. // whatever don't mess up the formatting.
$note = implode(' ', preg_split('/\s+/', $note)); $note = implode(' ', preg_split('/\s+/', $note));
$note = ' ('.phutil_utf8_shorten($note, 40, '...').')'; $note = ' ('.
id(new PhutilUTF8StringTruncator())
->setMaximumGlyphs(40)
->setTerminator('...')
->truncateString($note).
')';
} }
echo phutil_console_format( echo phutil_console_format(
"<fg:{$color}>%s</fg> flag%s $verb!\n", "<fg:{$color}>%s</fg> flag%s $verb!\n",