diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 5e7ed0be84..12cf628f35 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -358,6 +358,8 @@ phutil_register_library_map(array( 'DifferentialCustomFieldDependsOnParser' => 'applications/differential/field/parser/DifferentialCustomFieldDependsOnParser.php', 'DifferentialCustomFieldDependsOnParserTestCase' => 'applications/differential/field/parser/__tests__/DifferentialCustomFieldDependsOnParserTestCase.php', 'DifferentialCustomFieldNumericIndex' => 'applications/differential/storage/DifferentialCustomFieldNumericIndex.php', + 'DifferentialCustomFieldRevertsParser' => 'applications/differential/field/parser/DifferentialCustomFieldRevertsParser.php', + 'DifferentialCustomFieldRevertsParserTestCase' => 'applications/differential/field/parser/__tests__/DifferentialCustomFieldRevertsParserTestCase.php', 'DifferentialCustomFieldStorage' => 'applications/differential/storage/DifferentialCustomFieldStorage.php', 'DifferentialCustomFieldStringIndex' => 'applications/differential/storage/DifferentialCustomFieldStringIndex.php', 'DifferentialDAO' => 'applications/differential/storage/DifferentialDAO.php', @@ -387,7 +389,6 @@ phutil_register_library_map(array( 'DifferentialFieldSpecificationIncompleteException' => 'applications/differential/field/exception/DifferentialFieldSpecificationIncompleteException.php', 'DifferentialFieldValidationException' => 'applications/differential/field/exception/DifferentialFieldValidationException.php', 'DifferentialFreeformFieldSpecification' => 'applications/differential/field/specification/DifferentialFreeformFieldSpecification.php', - 'DifferentialFreeformFieldTestCase' => 'applications/differential/field/specification/__tests__/DifferentialFreeformFieldTestCase.php', 'DifferentialGetWorkingCopy' => 'applications/differential/DifferentialGetWorkingCopy.php', 'DifferentialGitSVNIDFieldSpecification' => 'applications/differential/field/specification/DifferentialGitSVNIDFieldSpecification.php', 'DifferentialHostFieldSpecification' => 'applications/differential/field/specification/DifferentialHostFieldSpecification.php', @@ -2876,6 +2877,8 @@ phutil_register_library_map(array( 'DifferentialCustomFieldDependsOnParser' => 'PhabricatorCustomFieldMonogramParser', 'DifferentialCustomFieldDependsOnParserTestCase' => 'PhabricatorTestCase', 'DifferentialCustomFieldNumericIndex' => 'PhabricatorCustomFieldNumericIndexStorage', + 'DifferentialCustomFieldRevertsParser' => 'PhabricatorCustomFieldMonogramParser', + 'DifferentialCustomFieldRevertsParserTestCase' => 'PhabricatorTestCase', 'DifferentialCustomFieldStorage' => 'PhabricatorCustomFieldStorage', 'DifferentialCustomFieldStringIndex' => 'PhabricatorCustomFieldStringIndexStorage', 'DifferentialDAO' => 'PhabricatorLiskDAO', @@ -2908,7 +2911,6 @@ phutil_register_library_map(array( 'DifferentialFieldSpecificationIncompleteException' => 'Exception', 'DifferentialFieldValidationException' => 'Exception', 'DifferentialFreeformFieldSpecification' => 'DifferentialFieldSpecification', - 'DifferentialFreeformFieldTestCase' => 'PhabricatorTestCase', 'DifferentialGitSVNIDFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialHostFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialHovercardEventListener' => 'PhabricatorEventListener', diff --git a/src/applications/differential/field/parser/DifferentialCustomFieldDependsOnParser.php b/src/applications/differential/field/parser/DifferentialCustomFieldDependsOnParser.php index adf0d5317d..e88a5d68be 100644 --- a/src/applications/differential/field/parser/DifferentialCustomFieldDependsOnParser.php +++ b/src/applications/differential/field/parser/DifferentialCustomFieldDependsOnParser.php @@ -26,7 +26,7 @@ final class DifferentialCustomFieldDependsOnParser } protected function getMonogramPattern() { - return 'D\d+'; + return '[Dd]\d+'; } } diff --git a/src/applications/differential/field/parser/DifferentialCustomFieldRevertsParser.php b/src/applications/differential/field/parser/DifferentialCustomFieldRevertsParser.php new file mode 100644 index 0000000000..02f1dbfe64 --- /dev/null +++ b/src/applications/differential/field/parser/DifferentialCustomFieldRevertsParser.php @@ -0,0 +1,51 @@ + 0, ), ), - 'depends on D123, D124' => array( + 'depends on D123, d124' => array( array( - 'match' => 'depends on D123, D124', + 'match' => 'depends on D123, d124', 'prefix' => 'depends on', 'infix' => '', - 'monograms' => array('D123', 'D124'), + 'monograms' => array('D123', 'd124'), 'suffix' => '', 'offset' => 0, ), diff --git a/src/applications/differential/field/parser/__tests__/DifferentialCustomFieldRevertsParserTestCase.php b/src/applications/differential/field/parser/__tests__/DifferentialCustomFieldRevertsParserTestCase.php new file mode 100644 index 0000000000..bb7a276319 --- /dev/null +++ b/src/applications/differential/field/parser/__tests__/DifferentialCustomFieldRevertsParserTestCase.php @@ -0,0 +1,92 @@ + array(), + + // Git default message. + 'This reverts commit 1234abcd.' => array( + array( + 'match' => 'reverts commit 1234abcd', + 'prefix' => 'reverts', + 'infix' => 'commit', + 'monograms' => array('1234abcd'), + 'suffix' => '', + 'offset' => 5, + ), + ), + + // Mercurial default message. + 'Backed out changeset 1234abcd.' => array( + array( + 'match' => 'Backed out changeset 1234abcd', + 'prefix' => 'Backed out', + 'infix' => 'changeset', + 'monograms' => array('1234abcd'), + 'suffix' => '', + 'offset' => 0, + ), + ), + + 'this undoes 1234abcd, 5678efab. they were bad' => array( + array( + 'match' => 'undoes 1234abcd, 5678efab', + 'prefix' => 'undoes', + 'infix' => '', + 'monograms' => array('1234abcd', '5678efab'), + 'suffix' => '', + 'offset' => 5, + ), + ), + + "Reverts 123" => array( + array( + 'match' => 'Reverts 123', + 'prefix' => 'Reverts', + 'infix' => '', + 'monograms' => array('123'), + 'suffix' => '', + 'offset' => 0, + ), + ), + + + "Reverts r123" => array( + array( + 'match' => 'Reverts r123', + 'prefix' => 'Reverts', + 'infix' => '', + 'monograms' => array('r123'), + 'suffix' => '', + 'offset' => 0, + ), + ), + + "Backs out commit\n99\n100" => array( + array( + 'match' => "Backs out commit\n99\n100", + 'prefix' => 'Backs out', + 'infix' => 'commit', + 'monograms' => array('99', '100'), + 'suffix' => '', + 'offset' => 0, + ), + ), + + "This doesn't revert anything" => array(), + 'nonrevert of r11' => array(), + "fixed a bug" => array(), + ); + + foreach ($map as $input => $expect) { + $parser = new DifferentialCustomFieldRevertsParser(); + $output = $parser->parseCorpus($input); + + $this->assertEqual($expect, $output, $input); + } + } + +} diff --git a/src/applications/differential/field/specification/__tests__/DifferentialFreeformFieldTestCase.php b/src/applications/differential/field/specification/__tests__/DifferentialFreeformFieldTestCase.php deleted file mode 100644 index 20b304aa40..0000000000 --- a/src/applications/differential/field/specification/__tests__/DifferentialFreeformFieldTestCase.php +++ /dev/null @@ -1,31 +0,0 @@ - array('123'), - "Reverts r123" => array('r123'), - "Reverts ac382f2" => array('ac382f2'), - "Reverts r22, r23" => array('r22', 'r23'), - "Reverts D99" => array('D99'), - "Backs out commit\n99\n100" => array('99', '100'), - "undo change f9f9f8f8" => array('f9f9f8f8'), - "Backedout Changeset rX1234" => array('rX1234'), - "This doesn't revert anything" => array(), - 'nonrevert of r11' => array(), - "fixed a bug" => array(), - ); - - foreach ($map as $input => $expect) { - $actual = array_values( - DifferentialFreeformFieldSpecification::findRevertedCommits($input)); - - $this->assertEqual( - $expect, - $actual, - "Reverted commits in: {$input}"); - } - } - -} diff --git a/src/infrastructure/customfield/parser/PhabricatorCustomFieldMonogramParser.php b/src/infrastructure/customfield/parser/PhabricatorCustomFieldMonogramParser.php index 6e59f1d93e..0a4c2aba7f 100644 --- a/src/infrastructure/customfield/parser/PhabricatorCustomFieldMonogramParser.php +++ b/src/infrastructure/customfield/parser/PhabricatorCustomFieldMonogramParser.php @@ -27,7 +27,7 @@ abstract class PhabricatorCustomFieldMonogramParser '((?:'.$monogram_pattern.'[,\s]*)+)'. $suffix_regex. '(?:$|\b)'. - '/i'; + '/'; $matches = null; $ok = preg_match_all( @@ -65,7 +65,7 @@ abstract class PhabricatorCustomFieldMonogramParser $maybe_tail = $final ? '' : '\s+'; $maybe_optional = $optional ? '?' : ''; - return '(?:('.$parts.')'.$maybe_tail.')'.$maybe_optional; + return '(?i:('.$parts.')'.$maybe_tail.')'.$maybe_optional; } }