Index: src/__phutil_library_map__.php =================================================================== --- src/__phutil_library_map__.php +++ src/__phutil_library_map__.php @@ -358,6 +358,8 @@ '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 @@ '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 @@ 'DifferentialCustomFieldDependsOnParser' => 'PhabricatorCustomFieldMonogramParser', 'DifferentialCustomFieldDependsOnParserTestCase' => 'PhabricatorTestCase', 'DifferentialCustomFieldNumericIndex' => 'PhabricatorCustomFieldNumericIndexStorage', + 'DifferentialCustomFieldRevertsParser' => 'PhabricatorCustomFieldMonogramParser', + 'DifferentialCustomFieldRevertsParserTestCase' => 'PhabricatorTestCase', 'DifferentialCustomFieldStorage' => 'PhabricatorCustomFieldStorage', 'DifferentialCustomFieldStringIndex' => 'PhabricatorCustomFieldStringIndexStorage', 'DifferentialDAO' => 'PhabricatorLiskDAO', @@ -2908,7 +2911,6 @@ 'DifferentialFieldSpecificationIncompleteException' => 'Exception', 'DifferentialFieldValidationException' => 'Exception', 'DifferentialFreeformFieldSpecification' => 'DifferentialFieldSpecification', - 'DifferentialFreeformFieldTestCase' => 'PhabricatorTestCase', 'DifferentialGitSVNIDFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialHostFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialHovercardEventListener' => 'PhabricatorEventListener', Index: src/applications/differential/field/parser/DifferentialCustomFieldDependsOnParser.php =================================================================== --- src/applications/differential/field/parser/DifferentialCustomFieldDependsOnParser.php +++ src/applications/differential/field/parser/DifferentialCustomFieldDependsOnParser.php @@ -26,7 +26,7 @@ } protected function getMonogramPattern() { - return 'D\d+'; + return '[Dd]\d+'; } } Index: src/applications/differential/field/parser/DifferentialCustomFieldRevertsParser.php =================================================================== --- /dev/null +++ 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, ), Index: src/applications/differential/field/parser/__tests__/DifferentialCustomFieldRevertsParserTestCase.php =================================================================== --- /dev/null +++ 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); + } + } + +} Index: src/applications/differential/field/specification/__tests__/DifferentialFreeformFieldTestCase.php =================================================================== --- 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}"); - } - } - -} Index: src/infrastructure/customfield/parser/PhabricatorCustomFieldMonogramParser.php =================================================================== --- src/infrastructure/customfield/parser/PhabricatorCustomFieldMonogramParser.php +++ src/infrastructure/customfield/parser/PhabricatorCustomFieldMonogramParser.php @@ -27,7 +27,7 @@ '((?:'.$monogram_pattern.'[,\s]*)+)'. $suffix_regex. '(?:$|\b)'. - '/i'; + '/'; $matches = null; $ok = preg_match_all( @@ -65,7 +65,7 @@ $maybe_tail = $final ? '' : '\s+'; $maybe_optional = $optional ? '?' : ''; - return '(?:('.$parts.')'.$maybe_tail.')'.$maybe_optional; + return '(?i:('.$parts.')'.$maybe_tail.')'.$maybe_optional; } }