Differential D17122 Diff 41185 src/applications/differential/parser/DifferentialCommitMessageParser.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/parser/DifferentialCommitMessageParser.php
| Show First 20 Lines • Show All 155 Lines • ▼ Show 20 Lines | public function parseCorpus($corpus) { | ||||
| $seen = array(); | $seen = array(); | ||||
| $lines = trim($corpus); | $lines = trim($corpus); | ||||
| $lines = phutil_split_lines($lines, false); | $lines = phutil_split_lines($lines, false); | ||||
| $field_map = array(); | $field_map = array(); | ||||
| foreach ($lines as $key => $line) { | foreach ($lines as $key => $line) { | ||||
| // We always parse the first line of the message as a title, even if it | |||||
| // contains something we recognize as a field header. | |||||
| if (!isset($seen[$key_title])) { | |||||
| $field = $key_title; | |||||
| $lines[$key] = trim($line); | |||||
| $seen[$field] = true; | |||||
| } else { | |||||
| $match = null; | $match = null; | ||||
| if (preg_match($label_regexp, $line, $match)) { | if (preg_match($label_regexp, $line, $match)) { | ||||
| $lines[$key] = trim($match['text']); | $lines[$key] = trim($match['text']); | ||||
| $field = $label_map[self::normalizeFieldLabel($match['field'])]; | $field = $label_map[self::normalizeFieldLabel($match['field'])]; | ||||
| if (!empty($seen[$field])) { | if (!empty($seen[$field])) { | ||||
| $this->errors[] = pht( | $this->errors[] = pht( | ||||
| 'Field "%s" occurs twice in commit message!', | 'Field "%s" occurs twice in commit message!', | ||||
| $field); | $match['field']); | ||||
epriestley: This is for T6050, I'll provide some context there. | |||||
| } | } | ||||
| $seen[$field] = true; | $seen[$field] = true; | ||||
| } | } | ||||
| } | |||||
| $field_map[$key] = $field; | $field_map[$key] = $field; | ||||
| } | } | ||||
| $fields = array(); | $fields = array(); | ||||
| foreach ($lines as $key => $line) { | foreach ($lines as $key => $line) { | ||||
| $fields[$field_map[$key]][] = $line; | $fields[$field_map[$key]][] = $line; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 189 Lines • Show Last 20 Lines | |||||
This is for T6050, I'll provide some context there.