Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15462037
D8262.id19661.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
10 KB
Referenced Files
None
Subscribers
None
D8262.id19661.diff
View Options
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 @@
+<?php
+
+final class DifferentialCustomFieldRevertsParser
+ extends PhabricatorCustomFieldMonogramParser {
+
+ protected function getPrefixes() {
+
+ // NOTE: Git language is "This reverts commit X."
+ // NOTE: Mercurial language is "Backed out changeset Y".
+
+ return array(
+ 'revert',
+ 'reverts',
+ 'reverted',
+ 'backout',
+ 'backsout',
+ 'backedout',
+ 'back out',
+ 'backs out',
+ 'backed out',
+ 'undo',
+ 'undoes',
+ );
+ }
+
+ protected function getInfixes() {
+ return array(
+ 'commit',
+ 'commits',
+ 'change',
+ 'changes',
+ 'changeset',
+ 'changesets',
+ 'rev',
+ 'revs',
+ 'revision',
+ 'revisions',
+ 'diff',
+ 'diffs',
+ );
+ }
+
+ protected function getSuffixes() {
+ return array();
+ }
+
+ protected function getMonogramPattern() {
+ return '[rA-Z0-9a-f]+';
+ }
+
+}
Index: src/applications/differential/field/parser/__tests__/DifferentialCustomFieldDependsOnParserTestCase.php
===================================================================
--- src/applications/differential/field/parser/__tests__/DifferentialCustomFieldDependsOnParserTestCase.php
+++ src/applications/differential/field/parser/__tests__/DifferentialCustomFieldDependsOnParserTestCase.php
@@ -27,12 +27,12 @@
'offset' => 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 @@
+<?php
+
+final class DifferentialCustomFieldRevertsParserTestCase
+ extends PhabricatorTestCase {
+
+ public function testParser() {
+ $map = array(
+ 'quack quack quack' => 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 @@
-<?php
-
-final class DifferentialFreeformFieldTestCase extends PhabricatorTestCase {
-
- public function testRevertedCommitParser() {
- $map = array(
- "Reverts 123" => 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;
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Apr 2 2025, 12:45 PM (4 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7729471
Default Alt Text
D8262.id19661.diff (10 KB)
Attached To
Mode
D8262: Bring "Reverts X" to more general infrastructure and port unit tests
Attached
Detach File
Event Timeline
Log In to Comment