1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +01:00

Add "and" support to "ref"

Summary: Fixes T8038. Allow `PhabricatorCustomFieldMonogramParser` to handle "and". This means that `Ref Tx, Ty and Tz` will correctly return `array('monograms' => array('Tx', 'Ty', 'Tz')`.

Test Plan: Added unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley

Maniphest Tasks: T2, T3, T1, T8038

Differential Revision: https://secure.phabricator.com/D12682
This commit is contained in:
Joshua Spence 2015-05-05 07:11:53 +10:00
parent 16ce63ec20
commit 6bebb3c69a
2 changed files with 19 additions and 2 deletions

View file

@ -60,6 +60,16 @@ final class ManiphestCustomFieldStatusParserTestCase
'offset' => 0,
),
),
'Fixes T123, T456, and T789.' => array(
array(
'match' => 'Fixes T123, T456, and T789',
'prefix' => 'Fixes',
'infix' => '',
'monograms' => array('T123', 'T456', 'T789'),
'suffix' => '',
'offset' => 0,
),
),
);
foreach ($map as $input => $expect) {

View file

@ -25,6 +25,7 @@ abstract class PhabricatorCustomFieldMonogramParser
$prefix_regex.
$infix_regex.
'((?:'.$monogram_pattern.'[,\s]*)+)'.
'(?:\band\s+('.$monogram_pattern.'))?'.
$suffix_regex.
'(?:$|\b)'.
'/';
@ -42,12 +43,18 @@ abstract class PhabricatorCustomFieldMonogramParser
$results = array();
foreach ($matches as $set) {
$monograms = array_filter(preg_split('/[,\s]+/', $set[3][0]));
if (isset($set[4]) && $set[4][0]) {
$monograms[] = $set[4][0];
}
$results[] = array(
'match' => $set[0][0],
'prefix' => $set[1][0],
'infix' => $set[2][0],
'monograms' => array_filter(preg_split('/[,\s]+/', $set[3][0])),
'suffix' => idx(idx($set, 4, array()), 0, ''),
'monograms' => $monograms,
'suffix' => idx(idx($set, 5, array()), 0, ''),
'offset' => $set[0][1],
);
}