@@ -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