mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-25 06:50:55 +01:00
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
This commit is contained in:
parent
ab17a7d4bf
commit
81e2a1cf6b
2 changed files with 30 additions and 9 deletions
|
@ -161,6 +161,14 @@ final class DifferentialCommitMessageParser extends Phobject {
|
||||||
|
|
||||||
$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']);
|
||||||
|
@ -168,10 +176,12 @@ final class DifferentialCommitMessageParser extends Phobject {
|
||||||
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']);
|
||||||
}
|
}
|
||||||
$seen[$field] = true;
|
$seen[$field] = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$field_map[$key] = $field;
|
$field_map[$key] = $field;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
color: orange
|
||||||
|
~~~~~~~~~~
|
||||||
|
{
|
||||||
|
"color": "color"
|
||||||
|
}
|
||||||
|
~~~~~~~~~~
|
||||||
|
{
|
||||||
|
"title": "color: orange"
|
||||||
|
}
|
||||||
|
~~~~~~~~~~
|
||||||
|
[]
|
Loading…
Reference in a new issue