From c8f15136c8c088dcba3084d5107bcede1774e1db Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Fri, 29 Aug 2014 15:15:18 -0700 Subject: [PATCH] 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 --- src/unit/engine/ArcanistXUnitTestResultParser.php | 4 +++- src/workflow/ArcanistDiffWorkflow.php | 4 +++- src/workflow/ArcanistFlagWorkflow.php | 7 ++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/unit/engine/ArcanistXUnitTestResultParser.php b/src/unit/engine/ArcanistXUnitTestResultParser.php index d8649172..3e04b779 100644 --- a/src/unit/engine/ArcanistXUnitTestResultParser.php +++ b/src/unit/engine/ArcanistXUnitTestResultParser.php @@ -24,7 +24,9 @@ final class ArcanistXUnitTestResultParser { $load_success = @$xunit_dom->loadXML($test_results); if (!$load_success) { - $input_start = phutil_utf8_shorten($test_results, 150); + $input_start = id(new PhutilUTF8StringTruncator()) + ->setMaximumGlyphs(150) + ->truncateString($test_results); throw new Exception( "Failed to load XUnit report; Input starts with:\n\n {$input_start}"); } diff --git a/src/workflow/ArcanistDiffWorkflow.php b/src/workflow/ArcanistDiffWorkflow.php index e174b464..de3818ee 100644 --- a/src/workflow/ArcanistDiffWorkflow.php +++ b/src/workflow/ArcanistDiffWorkflow.php @@ -1509,7 +1509,9 @@ EOTEXT $preview = explode("\n", $saved); $preview = array_shift($preview); $preview = trim($preview); - $preview = phutil_utf8_shorten($preview, 64); + $preview = id(new PhutilUTF8StringTruncator()) + ->setMaximumGlyphs(64) + ->truncateString($preview); if ($preview) { $preview = "Message begins:\n\n {$preview}\n\n"; diff --git a/src/workflow/ArcanistFlagWorkflow.php b/src/workflow/ArcanistFlagWorkflow.php index 4bbe7ee3..2a7e06c2 100644 --- a/src/workflow/ArcanistFlagWorkflow.php +++ b/src/workflow/ArcanistFlagWorkflow.php @@ -88,7 +88,12 @@ EOTEXT // Make sure notes that are long or have line breaks in them or // whatever don't mess up the formatting. $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( "%s flag%s $verb!\n",