Differential D7443 Diff 16771 src/applications/differential/conduit/ConduitAPI_differential_parsecommitmessage_Method.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/conduit/ConduitAPI_differential_parsecommitmessage_Method.php
Show First 20 Lines • Show All 163 Lines • ▼ Show 20 Lines | private function parseCommitMessage($corpus, array $label_map) { | ||||
// Implode all the lines back into chunks of text. | // Implode all the lines back into chunks of text. | ||||
foreach ($fields as $name => $lines) { | foreach ($fields as $name => $lines) { | ||||
$data = rtrim(implode("\n", $lines)); | $data = rtrim(implode("\n", $lines)); | ||||
$data = ltrim($data, "\n"); | $data = ltrim($data, "\n"); | ||||
$fields[$name] = $data; | $fields[$name] = $data; | ||||
} | } | ||||
// This is another piece of special-cased magic which allows you to | |||||
// enter a ridiculously long title, or just type a big block of stream | |||||
// of consciousness text, and have some sort of reasonable result conjured | |||||
// from it. | |||||
if (isset($fields['title'])) { | |||||
$terminal = '...'; | |||||
$title = $fields['title']; | |||||
$short = phutil_utf8_shorten($title, 250, $terminal); | |||||
if ($short != $title) { | |||||
// If we shortened the title, split the rest into the summary, so | |||||
// we end up with a title like: | |||||
// | |||||
// Title title tile title title... | |||||
// | |||||
// ...and a summary like: | |||||
// | |||||
// ...title title title. | |||||
// | |||||
// Summary summary summary summary. | |||||
$summary = idx($fields, 'summary', ''); | |||||
$offset = strlen($short) - strlen($terminal); | |||||
$remainder = ltrim(substr($fields['title'], $offset)); | |||||
$summary = '...'.$remainder."\n\n".$summary; | |||||
$summary = rtrim($summary, "\n"); | |||||
$fields['title'] = $short; | |||||
$fields['summary'] = $summary; | |||||
} | |||||
} | |||||
return $fields; | return $fields; | ||||
} | } | ||||
} | } |