@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Always parse the first line of a commit message as a title

Summary: Fixes T10312. If your first line is "Reviewers: xyz", it's a title, not a "Reviewers" field.

Test Plan: Added unit test.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10312

Differential Revision: https://secure.phabricator.com/D17122

+30 -9
+19 -9
src/applications/differential/parser/DifferentialCommitMessageParser.php
··· 161 161 162 162 $field_map = array(); 163 163 foreach ($lines as $key => $line) { 164 - $match = null; 165 - if (preg_match($label_regexp, $line, $match)) { 166 - $lines[$key] = trim($match['text']); 167 - $field = $label_map[self::normalizeFieldLabel($match['field'])]; 168 - if (!empty($seen[$field])) { 169 - $this->errors[] = pht( 170 - 'Field "%s" occurs twice in commit message!', 171 - $field); 172 - } 164 + // We always parse the first line of the message as a title, even if it 165 + // contains something we recognize as a field header. 166 + if (!isset($seen[$key_title])) { 167 + $field = $key_title; 168 + 169 + $lines[$key] = trim($line); 173 170 $seen[$field] = true; 171 + } else { 172 + $match = null; 173 + if (preg_match($label_regexp, $line, $match)) { 174 + $lines[$key] = trim($match['text']); 175 + $field = $label_map[self::normalizeFieldLabel($match['field'])]; 176 + if (!empty($seen[$field])) { 177 + $this->errors[] = pht( 178 + 'Field "%s" occurs twice in commit message!', 179 + $match['field']); 180 + } 181 + $seen[$field] = true; 182 + } 174 183 } 184 + 175 185 $field_map[$key] = $field; 176 186 } 177 187
+11
src/applications/differential/parser/__tests__/messages/title-with-label.txt
··· 1 + color: orange 2 + ~~~~~~~~~~ 3 + { 4 + "color": "color" 5 + } 6 + ~~~~~~~~~~ 7 + { 8 + "title": "color: orange" 9 + } 10 + ~~~~~~~~~~ 11 + []