Skip to content

Commit 29c7de6

Browse files
author
epriestley
committed
Split exceptionally huge revision titles into the summary
Summary: Fixes T4034. Test Plan: See screenshot. Reviewers: spicyj, btrahan Reviewed By: spicyj CC: aran Maniphest Tasks: T4034 Differential Revision: https://secure.phabricator.com/D7443
1 parent 1912455 commit 29c7de6

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/applications/differential/conduit/ConduitAPI_differential_parsecommitmessage_Method.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,38 @@ private function parseCommitMessage($corpus, array $label_map) {
169169
$fields[$name] = $data;
170170
}
171171

172+
// This is another piece of special-cased magic which allows you to
173+
// enter a ridiculously long title, or just type a big block of stream
174+
// of consciousness text, and have some sort of reasonable result conjured
175+
// from it.
176+
if (isset($fields['title'])) {
177+
$terminal = '...';
178+
$title = $fields['title'];
179+
$short = phutil_utf8_shorten($title, 250, $terminal);
180+
if ($short != $title) {
181+
182+
// If we shortened the title, split the rest into the summary, so
183+
// we end up with a title like:
184+
//
185+
// Title title tile title title...
186+
//
187+
// ...and a summary like:
188+
//
189+
// ...title title title.
190+
//
191+
// Summary summary summary summary.
192+
193+
$summary = idx($fields, 'summary', '');
194+
$offset = strlen($short) - strlen($terminal);
195+
$remainder = ltrim(substr($fields['title'], $offset));
196+
$summary = '...'.$remainder."\n\n".$summary;
197+
$summary = rtrim($summary, "\n");
198+
199+
$fields['title'] = $short;
200+
$fields['summary'] = $summary;
201+
}
202+
}
203+
172204
return $fields;
173205
}
174206

0 commit comments

Comments
 (0)