]> khamidou — GitHub mirrors - arcanist.git/commitdiff
phutil_utf8_shorten => PhutilUTF8StringTruncator
authorBob Trahan <btrahan@phacility.com>
Fri, 29 Aug 2014 22:15:18 +0000 (15:15 -0700)
committerBob Trahan <btrahan@phacility.com>
Fri, 29 Aug 2014 22:15:18 +0000 (15:15 -0700)
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
src/workflow/ArcanistDiffWorkflow.php
src/workflow/ArcanistFlagWorkflow.php

index d864917214e5ed6325f2ad1b95288ebe7291c598..3e04b779919067fad304c8daad3356c4b624bcab 100644 (file)
@@ -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}");
     }
index e174b464951e7c96fbe91291e212bf5d32b58a26..de3818ee761741a8d5d8a3f5dd5d3595e6adc5e9 100644 (file)
@@ -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";
index 4bbe7ee3d26963268bab6cc7269d762639f36a34..2a7e06c26bffcc97df456d952eda28db5c0d0612 100644 (file)
@@ -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(
       "<fg:{$color}>%s</fg> flag%s $verb!\n",