@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Modularize Herald Diffusion pre-commit content fields

Summary: Ref T8726. The gruntwork part of this is finally over.

Test Plan:
- Made a huge rule with every field.
- Applied migration.
- Verified the rule was still the same.
- Pushed a bunch of commits and verified transcripts.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T8726

Differential Revision: https://secure.phabricator.com/D13601

+815 -313
+146
resources/sql/autopatches/20150708.herald.3.sql
··· 1 + UPDATE {$NAMESPACE}_herald.herald_condition c 2 + JOIN {$NAMESPACE}_herald.herald_rule r 3 + ON c.ruleID = r.id 4 + SET c.fieldName = 'diffusion.pre.commit.message' 5 + WHERE r.contentType = 'HeraldPreCommitContentAdapter' 6 + AND c.fieldName = 'body'; 7 + 8 + UPDATE {$NAMESPACE}_herald.herald_condition c 9 + JOIN {$NAMESPACE}_herald.herald_rule r 10 + ON c.ruleID = r.id 11 + SET c.fieldName = 'diffusion.pre.commit.author' 12 + WHERE r.contentType = 'HeraldPreCommitContentAdapter' 13 + AND c.fieldName = 'author'; 14 + 15 + UPDATE {$NAMESPACE}_herald.herald_condition c 16 + JOIN {$NAMESPACE}_herald.herald_rule r 17 + ON c.ruleID = r.id 18 + SET c.fieldName = 'diffusion.pre.commit.author.raw' 19 + WHERE r.contentType = 'HeraldPreCommitContentAdapter' 20 + AND c.fieldName = 'author-raw'; 21 + 22 + UPDATE {$NAMESPACE}_herald.herald_condition c 23 + JOIN {$NAMESPACE}_herald.herald_rule r 24 + ON c.ruleID = r.id 25 + SET c.fieldName = 'diffusion.pre.commit.committer' 26 + WHERE r.contentType = 'HeraldPreCommitContentAdapter' 27 + AND c.fieldName = 'committer'; 28 + 29 + UPDATE {$NAMESPACE}_herald.herald_condition c 30 + JOIN {$NAMESPACE}_herald.herald_rule r 31 + ON c.ruleID = r.id 32 + SET c.fieldName = 'diffusion.pre.commit.committer.raw' 33 + WHERE r.contentType = 'HeraldPreCommitContentAdapter' 34 + AND c.fieldName = 'committer-raw'; 35 + 36 + UPDATE {$NAMESPACE}_herald.herald_condition c 37 + JOIN {$NAMESPACE}_herald.herald_rule r 38 + ON c.ruleID = r.id 39 + SET c.fieldName = 'diffusion.pre.commit.branches' 40 + WHERE r.contentType = 'HeraldPreCommitContentAdapter' 41 + AND c.fieldName = 'branches'; 42 + 43 + UPDATE {$NAMESPACE}_herald.herald_condition c 44 + JOIN {$NAMESPACE}_herald.herald_rule r 45 + ON c.ruleID = r.id 46 + SET c.fieldName = 'diffusion.pre.content.pusher' 47 + WHERE r.contentType = 'HeraldPreCommitContentAdapter' 48 + AND c.fieldName = 'pusher'; 49 + 50 + UPDATE {$NAMESPACE}_herald.herald_condition c 51 + JOIN {$NAMESPACE}_herald.herald_rule r 52 + ON c.ruleID = r.id 53 + SET c.fieldName = 'diffusion.pre.content.pusher.projects' 54 + WHERE r.contentType = 'HeraldPreCommitContentAdapter' 55 + AND c.fieldName = 'pusher-projects'; 56 + 57 + UPDATE {$NAMESPACE}_herald.herald_condition c 58 + JOIN {$NAMESPACE}_herald.herald_rule r 59 + ON c.ruleID = r.id 60 + SET c.fieldName = 'diffusion.pre.content.repository' 61 + WHERE r.contentType = 'HeraldPreCommitContentAdapter' 62 + AND c.fieldName = 'repository'; 63 + 64 + UPDATE {$NAMESPACE}_herald.herald_condition c 65 + JOIN {$NAMESPACE}_herald.herald_rule r 66 + ON c.ruleID = r.id 67 + SET c.fieldName = 'diffusion.pre.content.repository.projects' 68 + WHERE r.contentType = 'HeraldPreCommitContentAdapter' 69 + AND c.fieldName = 'repository-projects'; 70 + 71 + UPDATE {$NAMESPACE}_herald.herald_condition c 72 + JOIN {$NAMESPACE}_herald.herald_rule r 73 + ON c.ruleID = r.id 74 + SET c.fieldName = 'diffusion.pre.content.pusher.is-committer' 75 + WHERE r.contentType = 'HeraldPreCommitContentAdapter' 76 + AND c.fieldName = 'pusher-is-committer'; 77 + 78 + UPDATE {$NAMESPACE}_herald.herald_condition c 79 + JOIN {$NAMESPACE}_herald.herald_rule r 80 + ON c.ruleID = r.id 81 + SET c.fieldName = 'diffusion.pre.content.revision' 82 + WHERE r.contentType = 'HeraldPreCommitContentAdapter' 83 + AND c.fieldName = 'differential-revision'; 84 + 85 + UPDATE {$NAMESPACE}_herald.herald_condition c 86 + JOIN {$NAMESPACE}_herald.herald_rule r 87 + ON c.ruleID = r.id 88 + SET c.fieldName = 'diffusion.pre.content.revision.accepted' 89 + WHERE r.contentType = 'HeraldPreCommitContentAdapter' 90 + AND c.fieldName = 'differential-accepted'; 91 + 92 + UPDATE {$NAMESPACE}_herald.herald_condition c 93 + JOIN {$NAMESPACE}_herald.herald_rule r 94 + ON c.ruleID = r.id 95 + SET c.fieldName = 'diffusion.pre.content.revision.reviewers' 96 + WHERE r.contentType = 'HeraldPreCommitContentAdapter' 97 + AND c.fieldName = 'differential-reviewers'; 98 + 99 + UPDATE {$NAMESPACE}_herald.herald_condition c 100 + JOIN {$NAMESPACE}_herald.herald_rule r 101 + ON c.ruleID = r.id 102 + SET c.fieldName = 'diffusion.pre.content.revision.subscribers' 103 + WHERE r.contentType = 'HeraldPreCommitContentAdapter' 104 + AND c.fieldName = 'differential-ccs'; 105 + 106 + UPDATE {$NAMESPACE}_herald.herald_condition c 107 + JOIN {$NAMESPACE}_herald.herald_rule r 108 + ON c.ruleID = r.id 109 + SET c.fieldName = 'diffusion.pre.content.diff.enormous' 110 + WHERE r.contentType = 'HeraldPreCommitContentAdapter' 111 + AND c.fieldName = 'diff-enormous'; 112 + 113 + UPDATE {$NAMESPACE}_herald.herald_condition c 114 + JOIN {$NAMESPACE}_herald.herald_rule r 115 + ON c.ruleID = r.id 116 + SET c.fieldName = 'diffusion.pre.commit.affected' 117 + WHERE r.contentType = 'HeraldPreCommitContentAdapter' 118 + AND c.fieldName = 'diff-file'; 119 + 120 + UPDATE {$NAMESPACE}_herald.herald_condition c 121 + JOIN {$NAMESPACE}_herald.herald_rule r 122 + ON c.ruleID = r.id 123 + SET c.fieldName = 'diffusion.pre.commit.diff.content' 124 + WHERE r.contentType = 'HeraldPreCommitContentAdapter' 125 + AND c.fieldName = 'diff-content'; 126 + 127 + UPDATE {$NAMESPACE}_herald.herald_condition c 128 + JOIN {$NAMESPACE}_herald.herald_rule r 129 + ON c.ruleID = r.id 130 + SET c.fieldName = 'diffusion.pre.commit.diff.new' 131 + WHERE r.contentType = 'HeraldPreCommitContentAdapter' 132 + AND c.fieldName = 'diff-added-content'; 133 + 134 + UPDATE {$NAMESPACE}_herald.herald_condition c 135 + JOIN {$NAMESPACE}_herald.herald_rule r 136 + ON c.ruleID = r.id 137 + SET c.fieldName = 'diffusion.pre.commit.diff.old' 138 + WHERE r.contentType = 'HeraldPreCommitContentAdapter' 139 + AND c.fieldName = 'diff-removed-content'; 140 + 141 + UPDATE {$NAMESPACE}_herald.herald_condition c 142 + JOIN {$NAMESPACE}_herald.herald_rule r 143 + ON c.ruleID = r.id 144 + SET c.fieldName = 'diffusion.pre.content.merge' 145 + WHERE r.contentType = 'HeraldPreCommitContentAdapter' 146 + AND c.fieldName = 'is-merge-commit';
+44
src/__phutil_library_map__.php
··· 616 616 'DiffusionPathTreeController' => 'applications/diffusion/controller/DiffusionPathTreeController.php', 617 617 'DiffusionPathValidateController' => 'applications/diffusion/controller/DiffusionPathValidateController.php', 618 618 'DiffusionPhpExternalSymbolsSource' => 'applications/diffusion/symbol/DiffusionPhpExternalSymbolsSource.php', 619 + 'DiffusionPreCommitContentAffectedFilesHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentAffectedFilesHeraldField.php', 620 + 'DiffusionPreCommitContentAuthorHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentAuthorHeraldField.php', 621 + 'DiffusionPreCommitContentAuthorRawHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentAuthorRawHeraldField.php', 622 + 'DiffusionPreCommitContentBranchesHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentBranchesHeraldField.php', 623 + 'DiffusionPreCommitContentCommitterHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentCommitterHeraldField.php', 624 + 'DiffusionPreCommitContentCommitterRawHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentCommitterRawHeraldField.php', 625 + 'DiffusionPreCommitContentDiffContentAddedHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentDiffContentAddedHeraldField.php', 626 + 'DiffusionPreCommitContentDiffContentHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentDiffContentHeraldField.php', 627 + 'DiffusionPreCommitContentDiffContentRemovedHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentDiffContentRemovedHeraldField.php', 628 + 'DiffusionPreCommitContentDiffEnormousHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentDiffEnormousHeraldField.php', 629 + 'DiffusionPreCommitContentHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentHeraldField.php', 630 + 'DiffusionPreCommitContentMergeHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentMergeHeraldField.php', 631 + 'DiffusionPreCommitContentMessageHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentMessageHeraldField.php', 632 + 'DiffusionPreCommitContentPusherHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentPusherHeraldField.php', 633 + 'DiffusionPreCommitContentPusherIsCommitterHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentPusherIsCommitterHeraldField.php', 634 + 'DiffusionPreCommitContentPusherProjectsHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentPusherProjectsHeraldField.php', 635 + 'DiffusionPreCommitContentRepositoryHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentRepositoryHeraldField.php', 636 + 'DiffusionPreCommitContentRepositoryProjectsHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentRepositoryProjectsHeraldField.php', 637 + 'DiffusionPreCommitContentRevisionAcceptedHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentRevisionAcceptedHeraldField.php', 638 + 'DiffusionPreCommitContentRevisionHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentRevisionHeraldField.php', 639 + 'DiffusionPreCommitContentRevisionReviewersHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentRevisionReviewersHeraldField.php', 640 + 'DiffusionPreCommitContentRevisionSubscribersHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentRevisionSubscribersHeraldField.php', 619 641 'DiffusionPreCommitRefChangeHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitRefChangeHeraldField.php', 620 642 'DiffusionPreCommitRefHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitRefHeraldField.php', 621 643 'DiffusionPreCommitRefNameHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitRefNameHeraldField.php', ··· 4107 4129 'DiffusionPathTreeController' => 'DiffusionController', 4108 4130 'DiffusionPathValidateController' => 'DiffusionController', 4109 4131 'DiffusionPhpExternalSymbolsSource' => 'DiffusionExternalSymbolsSource', 4132 + 'DiffusionPreCommitContentAffectedFilesHeraldField' => 'DiffusionPreCommitContentHeraldField', 4133 + 'DiffusionPreCommitContentAuthorHeraldField' => 'DiffusionPreCommitContentHeraldField', 4134 + 'DiffusionPreCommitContentAuthorRawHeraldField' => 'DiffusionPreCommitContentHeraldField', 4135 + 'DiffusionPreCommitContentBranchesHeraldField' => 'DiffusionPreCommitContentHeraldField', 4136 + 'DiffusionPreCommitContentCommitterHeraldField' => 'DiffusionPreCommitContentHeraldField', 4137 + 'DiffusionPreCommitContentCommitterRawHeraldField' => 'DiffusionPreCommitContentHeraldField', 4138 + 'DiffusionPreCommitContentDiffContentAddedHeraldField' => 'DiffusionPreCommitContentHeraldField', 4139 + 'DiffusionPreCommitContentDiffContentHeraldField' => 'DiffusionPreCommitContentHeraldField', 4140 + 'DiffusionPreCommitContentDiffContentRemovedHeraldField' => 'DiffusionPreCommitContentHeraldField', 4141 + 'DiffusionPreCommitContentDiffEnormousHeraldField' => 'DiffusionPreCommitContentHeraldField', 4142 + 'DiffusionPreCommitContentHeraldField' => 'HeraldField', 4143 + 'DiffusionPreCommitContentMergeHeraldField' => 'DiffusionPreCommitContentHeraldField', 4144 + 'DiffusionPreCommitContentMessageHeraldField' => 'DiffusionPreCommitContentHeraldField', 4145 + 'DiffusionPreCommitContentPusherHeraldField' => 'DiffusionPreCommitContentHeraldField', 4146 + 'DiffusionPreCommitContentPusherIsCommitterHeraldField' => 'DiffusionPreCommitContentHeraldField', 4147 + 'DiffusionPreCommitContentPusherProjectsHeraldField' => 'DiffusionPreCommitContentHeraldField', 4148 + 'DiffusionPreCommitContentRepositoryHeraldField' => 'DiffusionPreCommitContentHeraldField', 4149 + 'DiffusionPreCommitContentRepositoryProjectsHeraldField' => 'DiffusionPreCommitContentHeraldField', 4150 + 'DiffusionPreCommitContentRevisionAcceptedHeraldField' => 'DiffusionPreCommitContentHeraldField', 4151 + 'DiffusionPreCommitContentRevisionHeraldField' => 'DiffusionPreCommitContentHeraldField', 4152 + 'DiffusionPreCommitContentRevisionReviewersHeraldField' => 'DiffusionPreCommitContentHeraldField', 4153 + 'DiffusionPreCommitContentRevisionSubscribersHeraldField' => 'DiffusionPreCommitContentHeraldField', 4110 4154 'DiffusionPreCommitRefChangeHeraldField' => 'DiffusionPreCommitRefHeraldField', 4111 4155 'DiffusionPreCommitRefHeraldField' => 'HeraldField', 4112 4156 'DiffusionPreCommitRefNameHeraldField' => 'DiffusionPreCommitRefHeraldField',
+24
src/applications/diffusion/herald/DiffusionPreCommitContentAffectedFilesHeraldField.php
··· 1 + <?php 2 + 3 + final class DiffusionPreCommitContentAffectedFilesHeraldField 4 + extends DiffusionPreCommitContentHeraldField { 5 + 6 + const FIELDCONST = 'diffusion.pre.commit.affected'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Affected files'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + return $this->getAdapter()->getDiffContent('name'); 14 + } 15 + 16 + protected function getHeraldFieldStandardConditions() { 17 + return self::STANDARD_TEXT_LIST; 18 + } 19 + 20 + public function getHeraldFieldValueType($condition) { 21 + return HeraldAdapter::VALUE_TEXT; 22 + } 23 + 24 + }
+30
src/applications/diffusion/herald/DiffusionPreCommitContentAuthorHeraldField.php
··· 1 + <?php 2 + 3 + final class DiffusionPreCommitContentAuthorHeraldField 4 + extends DiffusionPreCommitContentHeraldField { 5 + 6 + const FIELDCONST = 'diffusion.pre.commit.author'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Author'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + return $this->getAdapter()->getAuthorPHID(); 14 + } 15 + 16 + protected function getHeraldFieldStandardConditions() { 17 + return self::STANDARD_PHID_NULLABLE; 18 + } 19 + 20 + public function getHeraldFieldValueType($condition) { 21 + switch ($condition) { 22 + case HeraldAdapter::CONDITION_EXISTS: 23 + case HeraldAdapter::CONDITION_NOT_EXISTS: 24 + return HeraldAdapter::VALUE_NONE; 25 + default: 26 + return HeraldAdapter::VALUE_USER; 27 + } 28 + } 29 + 30 + }
+24
src/applications/diffusion/herald/DiffusionPreCommitContentAuthorRawHeraldField.php
··· 1 + <?php 2 + 3 + final class DiffusionPreCommitContentAuthorRawHeraldField 4 + extends DiffusionPreCommitContentHeraldField { 5 + 6 + const FIELDCONST = 'diffusion.pre.commit.author.raw'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Raw Author'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + return $this->getAdapter()->getAuthorRaw(); 14 + } 15 + 16 + protected function getHeraldFieldStandardConditions() { 17 + return self::STANDARD_TEXT; 18 + } 19 + 20 + public function getHeraldFieldValueType($condition) { 21 + return HeraldAdapter::VALUE_TEXT; 22 + } 23 + 24 + }
+24
src/applications/diffusion/herald/DiffusionPreCommitContentBranchesHeraldField.php
··· 1 + <?php 2 + 3 + final class DiffusionPreCommitContentBranchesHeraldField 4 + extends DiffusionPreCommitContentHeraldField { 5 + 6 + const FIELDCONST = 'diffusion.pre.commit.branches'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Branches'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + return $this->getAdapter()->getBranches(); 14 + } 15 + 16 + protected function getHeraldFieldStandardConditions() { 17 + return self::STANDARD_TEXT_LIST; 18 + } 19 + 20 + public function getHeraldFieldValueType($condition) { 21 + return HeraldAdapter::VALUE_TEXT; 22 + } 23 + 24 + }
+30
src/applications/diffusion/herald/DiffusionPreCommitContentCommitterHeraldField.php
··· 1 + <?php 2 + 3 + final class DiffusionPreCommitContentCommitterHeraldField 4 + extends DiffusionPreCommitContentHeraldField { 5 + 6 + const FIELDCONST = 'diffusion.pre.commit.committer'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Committer'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + return $this->getAdapter()->getCommitterPHID(); 14 + } 15 + 16 + protected function getHeraldFieldStandardConditions() { 17 + return self::STANDARD_PHID_NULLABLE; 18 + } 19 + 20 + public function getHeraldFieldValueType($condition) { 21 + switch ($condition) { 22 + case HeraldAdapter::CONDITION_EXISTS: 23 + case HeraldAdapter::CONDITION_NOT_EXISTS: 24 + return HeraldAdapter::VALUE_NONE; 25 + default: 26 + return HeraldAdapter::VALUE_USER; 27 + } 28 + } 29 + 30 + }
+24
src/applications/diffusion/herald/DiffusionPreCommitContentCommitterRawHeraldField.php
··· 1 + <?php 2 + 3 + final class DiffusionPreCommitContentCommitterRawHeraldField 4 + extends DiffusionPreCommitContentHeraldField { 5 + 6 + const FIELDCONST = 'diffusion.pre.commit.committer.raw'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Raw Committer'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + return $this->getAdapter()->getCommitterRaw(); 14 + } 15 + 16 + protected function getHeraldFieldStandardConditions() { 17 + return self::STANDARD_TEXT; 18 + } 19 + 20 + public function getHeraldFieldValueType($condition) { 21 + return HeraldAdapter::VALUE_TEXT; 22 + } 23 + 24 + }
+24
src/applications/diffusion/herald/DiffusionPreCommitContentDiffContentAddedHeraldField.php
··· 1 + <?php 2 + 3 + final class DiffusionPreCommitContentDiffContentAddedHeraldField 4 + extends DiffusionPreCommitContentHeraldField { 5 + 6 + const FIELDCONST = 'diffusion.pre.commit.diff.new'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Added diff content'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + return $this->getAdapter()->getDiffContent('+'); 14 + } 15 + 16 + protected function getHeraldFieldStandardConditions() { 17 + return self::STANDARD_TEXT_MAP; 18 + } 19 + 20 + public function getHeraldFieldValueType($condition) { 21 + return HeraldAdapter::VALUE_TEXT; 22 + } 23 + 24 + }
+24
src/applications/diffusion/herald/DiffusionPreCommitContentDiffContentHeraldField.php
··· 1 + <?php 2 + 3 + final class DiffusionPreCommitContentDiffContentHeraldField 4 + extends DiffusionPreCommitContentHeraldField { 5 + 6 + const FIELDCONST = 'diffusion.pre.commit.diff.content'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Diff content'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + return $this->getAdapter()->getDiffContent('*'); 14 + } 15 + 16 + protected function getHeraldFieldStandardConditions() { 17 + return self::STANDARD_TEXT_MAP; 18 + } 19 + 20 + public function getHeraldFieldValueType($condition) { 21 + return HeraldAdapter::VALUE_TEXT; 22 + } 23 + 24 + }
+24
src/applications/diffusion/herald/DiffusionPreCommitContentDiffContentRemovedHeraldField.php
··· 1 + <?php 2 + 3 + final class DiffusionPreCommitContentDiffContentRemovedHeraldField 4 + extends DiffusionPreCommitContentHeraldField { 5 + 6 + const FIELDCONST = 'diffusion.pre.commit.diff.old'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Removed diff content'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + return $this->getAdapter()->getDiffContent('-'); 14 + } 15 + 16 + protected function getHeraldFieldStandardConditions() { 17 + return self::STANDARD_TEXT_MAP; 18 + } 19 + 20 + public function getHeraldFieldValueType($condition) { 21 + return HeraldAdapter::VALUE_TEXT; 22 + } 23 + 24 + }
+24
src/applications/diffusion/herald/DiffusionPreCommitContentDiffEnormousHeraldField.php
··· 1 + <?php 2 + 3 + final class DiffusionPreCommitContentDiffEnormousHeraldField 4 + extends DiffusionPreCommitContentHeraldField { 5 + 6 + const FIELDCONST = 'diffusion.pre.content.diff.enormous'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Diff is enormous'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + return $this->getAdapter()->isDiffEnormous(); 14 + } 15 + 16 + protected function getHeraldFieldStandardConditions() { 17 + return HeraldField::STANDARD_BOOL; 18 + } 19 + 20 + public function getHeraldFieldValueType($condition) { 21 + return HeraldAdapter::VALUE_NONE; 22 + } 23 + 24 + }
+17
src/applications/diffusion/herald/DiffusionPreCommitContentHeraldField.php
··· 1 + <?php 2 + 3 + abstract class DiffusionPreCommitContentHeraldField extends HeraldField { 4 + 5 + public function supportsObject($object) { 6 + if (!($object instanceof PhabricatorRepositoryPushLog)) { 7 + return false; 8 + } 9 + 10 + if ($this->getAdapter()->isPreCommitRefAdapter()) { 11 + return false; 12 + } 13 + 14 + return true; 15 + } 16 + 17 + }
+24
src/applications/diffusion/herald/DiffusionPreCommitContentMergeHeraldField.php
··· 1 + <?php 2 + 3 + final class DiffusionPreCommitContentMergeHeraldField 4 + extends DiffusionPreCommitContentHeraldField { 5 + 6 + const FIELDCONST = 'diffusion.pre.content.merge'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Is merge commit'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + return $this->getAdapter()->getIsMergeCommit(); 14 + } 15 + 16 + protected function getHeraldFieldStandardConditions() { 17 + return HeraldField::STANDARD_BOOL; 18 + } 19 + 20 + public function getHeraldFieldValueType($condition) { 21 + return HeraldAdapter::VALUE_NONE; 22 + } 23 + 24 + }
+24
src/applications/diffusion/herald/DiffusionPreCommitContentMessageHeraldField.php
··· 1 + <?php 2 + 3 + final class DiffusionPreCommitContentMessageHeraldField 4 + extends DiffusionPreCommitContentHeraldField { 5 + 6 + const FIELDCONST = 'diffusion.pre.commit.message'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Commit message'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + return $this->getAdapter()->getCommitRef()->getMessage(); 14 + } 15 + 16 + protected function getHeraldFieldStandardConditions() { 17 + return self::STANDARD_TEXT; 18 + } 19 + 20 + public function getHeraldFieldValueType($condition) { 21 + return HeraldAdapter::VALUE_TEXT; 22 + } 23 + 24 + }
+24
src/applications/diffusion/herald/DiffusionPreCommitContentPusherHeraldField.php
··· 1 + <?php 2 + 3 + final class DiffusionPreCommitContentPusherHeraldField 4 + extends DiffusionPreCommitContentHeraldField { 5 + 6 + const FIELDCONST = 'diffusion.pre.content.pusher'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Pusher'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + return $this->getAdapter()->getHookEngine()->getViewer()->getPHID(); 14 + } 15 + 16 + protected function getHeraldFieldStandardConditions() { 17 + return HeraldField::STANDARD_PHID; 18 + } 19 + 20 + public function getHeraldFieldValueType($condition) { 21 + return HeraldAdapter::VALUE_USER; 22 + } 23 + 24 + }
+27
src/applications/diffusion/herald/DiffusionPreCommitContentPusherIsCommitterHeraldField.php
··· 1 + <?php 2 + 3 + final class DiffusionPreCommitContentPusherIsCommitterHeraldField 4 + extends DiffusionPreCommitContentHeraldField { 5 + 6 + const FIELDCONST = 'diffusion.pre.content.pusher.is-committer'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Pusher is committer'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + $pusher = $this->getAdapter()->getHookEngine()->getViewer()->getPHID(); 14 + $committer = $this->getAdapter()->getCommitterPHID(); 15 + 16 + return ($pusher === $committer); 17 + } 18 + 19 + protected function getHeraldFieldStandardConditions() { 20 + return HeraldField::STANDARD_BOOL; 21 + } 22 + 23 + public function getHeraldFieldValueType($condition) { 24 + return HeraldAdapter::VALUE_NONE; 25 + } 26 + 27 + }
+31
src/applications/diffusion/herald/DiffusionPreCommitContentPusherProjectsHeraldField.php
··· 1 + <?php 2 + 3 + final class DiffusionPreCommitContentPusherProjectsHeraldField 4 + extends DiffusionPreCommitContentHeraldField { 5 + 6 + const FIELDCONST = 'diffusion.pre.content.pusher.projects'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Pusher projects'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + return $this->getAdapter() 14 + ->getHookEngine() 15 + ->loadViewerProjectPHIDsForHerald(); 16 + } 17 + 18 + protected function getHeraldFieldStandardConditions() { 19 + return HeraldField::STANDARD_LIST; 20 + } 21 + 22 + public function getHeraldFieldValueType($condition) { 23 + switch ($condition) { 24 + case HeraldAdapter::CONDITION_EXISTS: 25 + case HeraldAdapter::CONDITION_NOT_EXISTS: 26 + return HeraldAdapter::VALUE_NONE; 27 + default: 28 + return HeraldAdapter::VALUE_PROJECT; 29 + } 30 + } 31 + }
+24
src/applications/diffusion/herald/DiffusionPreCommitContentRepositoryHeraldField.php
··· 1 + <?php 2 + 3 + final class DiffusionPreCommitContentRepositoryHeraldField 4 + extends DiffusionPreCommitContentHeraldField { 5 + 6 + const FIELDCONST = 'diffusion.pre.content.repository'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Repository'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + return $this->getAdapter()->getHookEngine()->getRepository()->getPHID(); 14 + } 15 + 16 + protected function getHeraldFieldStandardConditions() { 17 + return HeraldField::STANDARD_PHID; 18 + } 19 + 20 + public function getHeraldFieldValueType($condition) { 21 + return HeraldAdapter::VALUE_REPOSITORY; 22 + } 23 + 24 + }
+32
src/applications/diffusion/herald/DiffusionPreCommitContentRepositoryProjectsHeraldField.php
··· 1 + <?php 2 + 3 + final class DiffusionPreCommitContentRepositoryProjectsHeraldField 4 + extends DiffusionPreCommitContentHeraldField { 5 + 6 + const FIELDCONST = 'diffusion.pre.content.repository.projects'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Repository projects'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + return PhabricatorEdgeQuery::loadDestinationPHIDs( 14 + $this->getAdapter()->getHookEngine()->getRepository()->getPHID(), 15 + PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); 16 + } 17 + 18 + protected function getHeraldFieldStandardConditions() { 19 + return HeraldField::STANDARD_LIST; 20 + } 21 + 22 + public function getHeraldFieldValueType($condition) { 23 + switch ($condition) { 24 + case HeraldAdapter::CONDITION_EXISTS: 25 + case HeraldAdapter::CONDITION_NOT_EXISTS: 26 + return HeraldAdapter::VALUE_NONE; 27 + default: 28 + return HeraldAdapter::VALUE_PROJECT; 29 + } 30 + } 31 + 32 + }
+35
src/applications/diffusion/herald/DiffusionPreCommitContentRevisionAcceptedHeraldField.php
··· 1 + <?php 2 + 3 + final class DiffusionPreCommitContentRevisionAcceptedHeraldField 4 + extends DiffusionPreCommitContentHeraldField { 5 + 6 + const FIELDCONST = 'diffusion.pre.content.revision.accepted'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Accepted Differential revision'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + $revision = $this->getAdapter()->getRevision(); 14 + 15 + if (!$revision) { 16 + return null; 17 + } 18 + 19 + $status_accepted = ArcanistDifferentialRevisionStatus::ACCEPTED; 20 + if ($revision->getStatus() != $status_accepted) { 21 + return null; 22 + } 23 + 24 + return $revision->getPHID(); 25 + } 26 + 27 + protected function getHeraldFieldStandardConditions() { 28 + return self::STANDARD_PHID_BOOL; 29 + } 30 + 31 + public function getHeraldFieldValueType($condition) { 32 + return HeraldAdapter::VALUE_NONE; 33 + } 34 + 35 + }
+30
src/applications/diffusion/herald/DiffusionPreCommitContentRevisionHeraldField.php
··· 1 + <?php 2 + 3 + final class DiffusionPreCommitContentRevisionHeraldField 4 + extends DiffusionPreCommitContentHeraldField { 5 + 6 + const FIELDCONST = 'diffusion.pre.content.revision'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Differential revision'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + $revision = $this->getAdapter()->getRevision(); 14 + 15 + if (!$revision) { 16 + return null; 17 + } 18 + 19 + return $revision->getPHID(); 20 + } 21 + 22 + protected function getHeraldFieldStandardConditions() { 23 + return self::STANDARD_PHID_BOOL; 24 + } 25 + 26 + public function getHeraldFieldValueType($condition) { 27 + return HeraldAdapter::VALUE_NONE; 28 + } 29 + 30 + }
+36
src/applications/diffusion/herald/DiffusionPreCommitContentRevisionReviewersHeraldField.php
··· 1 + <?php 2 + 3 + final class DiffusionPreCommitContentRevisionReviewersHeraldField 4 + extends DiffusionPreCommitContentHeraldField { 5 + 6 + const FIELDCONST = 'diffusion.pre.content.revision.reviewers'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Differential reviewers'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + $revision = $this->getAdapter()->getRevision(); 14 + 15 + if (!$revision) { 16 + return array(); 17 + } 18 + 19 + return $revision->getReviewers(); 20 + } 21 + 22 + protected function getHeraldFieldStandardConditions() { 23 + return self::STANDARD_LIST; 24 + } 25 + 26 + public function getHeraldFieldValueType($condition) { 27 + switch ($condition) { 28 + case HeraldAdapter::CONDITION_EXISTS: 29 + case HeraldAdapter::CONDITION_NOT_EXISTS: 30 + return HeraldAdapter::VALUE_NONE; 31 + default: 32 + return HeraldAdapter::VALUE_USER_OR_PROJECT; 33 + } 34 + } 35 + 36 + }
+37
src/applications/diffusion/herald/DiffusionPreCommitContentRevisionSubscribersHeraldField.php
··· 1 + <?php 2 + 3 + final class DiffusionPreCommitContentRevisionSubscribersHeraldField 4 + extends DiffusionPreCommitContentHeraldField { 5 + 6 + const FIELDCONST = 'diffusion.pre.content.revision.subscribers'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Differential subscribers'); 10 + } 11 + 12 + public function getHeraldFieldValue($object) { 13 + $revision = $this->getAdapter()->getRevision(); 14 + 15 + if (!$revision) { 16 + return array(); 17 + } 18 + 19 + $phid = $revision->getPHID(); 20 + return PhabricatorSubscribersQuery::loadSubscribersForPHID($phid); 21 + } 22 + 23 + protected function getHeraldFieldStandardConditions() { 24 + return self::STANDARD_LIST; 25 + } 26 + 27 + public function getHeraldFieldValueType($condition) { 28 + switch ($condition) { 29 + case HeraldAdapter::CONDITION_EXISTS: 30 + case HeraldAdapter::CONDITION_NOT_EXISTS: 31 + return HeraldAdapter::VALUE_NONE; 32 + default: 33 + return HeraldAdapter::VALUE_USER_OR_PROJECT; 34 + } 35 + } 36 + 37 + }
+12 -107
src/applications/diffusion/herald/HeraldPreCommitContentAdapter.php
··· 25 25 return false; 26 26 } 27 27 28 - public function getFields() { 29 - return array_merge( 30 - array( 31 - self::FIELD_BODY, 32 - self::FIELD_AUTHOR, 33 - self::FIELD_AUTHOR_RAW, 34 - self::FIELD_COMMITTER, 35 - self::FIELD_COMMITTER_RAW, 36 - self::FIELD_BRANCHES, 37 - self::FIELD_DIFF_FILE, 38 - self::FIELD_DIFF_CONTENT, 39 - self::FIELD_DIFF_ADDED_CONTENT, 40 - self::FIELD_DIFF_REMOVED_CONTENT, 41 - self::FIELD_DIFF_ENORMOUS, 42 - self::FIELD_REPOSITORY, 43 - self::FIELD_REPOSITORY_PROJECTS, 44 - self::FIELD_PUSHER, 45 - self::FIELD_PUSHER_PROJECTS, 46 - self::FIELD_PUSHER_IS_COMMITTER, 47 - self::FIELD_DIFFERENTIAL_REVISION, 48 - self::FIELD_DIFFERENTIAL_ACCEPTED, 49 - self::FIELD_DIFFERENTIAL_REVIEWERS, 50 - self::FIELD_DIFFERENTIAL_CCS, 51 - self::FIELD_IS_MERGE_COMMIT, 52 - ), 53 - parent::getFields()); 54 - } 55 - 56 28 public function getHeraldName() { 57 29 return pht('Push Log (Content)'); 58 30 } 59 31 60 - public function getHeraldField($field) { 61 - $log = $this->getObject(); 62 - switch ($field) { 63 - case self::FIELD_BODY: 64 - return $this->getCommitRef()->getMessage(); 65 - case self::FIELD_AUTHOR: 66 - return $this->getAuthorPHID(); 67 - case self::FIELD_AUTHOR_RAW: 68 - return $this->getAuthorRaw(); 69 - case self::FIELD_COMMITTER: 70 - return $this->getCommitterPHID(); 71 - case self::FIELD_COMMITTER_RAW: 72 - return $this->getCommitterRaw(); 73 - case self::FIELD_BRANCHES: 74 - return $this->getBranches(); 75 - case self::FIELD_DIFF_FILE: 76 - return $this->getDiffContent('name'); 77 - case self::FIELD_DIFF_CONTENT: 78 - return $this->getDiffContent('*'); 79 - case self::FIELD_DIFF_ADDED_CONTENT: 80 - return $this->getDiffContent('+'); 81 - case self::FIELD_DIFF_REMOVED_CONTENT: 82 - return $this->getDiffContent('-'); 83 - case self::FIELD_DIFF_ENORMOUS: 84 - $this->getDiffContent('*'); 85 - return ($this->changesets instanceof Exception); 86 - case self::FIELD_REPOSITORY: 87 - return $this->getHookEngine()->getRepository()->getPHID(); 88 - case self::FIELD_REPOSITORY_PROJECTS: 89 - return $this->getHookEngine()->getRepository()->getProjectPHIDs(); 90 - case self::FIELD_PUSHER: 91 - return $this->getHookEngine()->getViewer()->getPHID(); 92 - case self::FIELD_PUSHER_PROJECTS: 93 - return $this->getHookEngine()->loadViewerProjectPHIDsForHerald(); 94 - case self::FIELD_DIFFERENTIAL_REVISION: 95 - $revision = $this->getRevision(); 96 - if (!$revision) { 97 - return null; 98 - } 99 - return $revision->getPHID(); 100 - case self::FIELD_DIFFERENTIAL_ACCEPTED: 101 - $revision = $this->getRevision(); 102 - if (!$revision) { 103 - return null; 104 - } 105 - $status_accepted = ArcanistDifferentialRevisionStatus::ACCEPTED; 106 - if ($revision->getStatus() != $status_accepted) { 107 - return null; 108 - } 109 - return $revision->getPHID(); 110 - case self::FIELD_DIFFERENTIAL_REVIEWERS: 111 - $revision = $this->getRevision(); 112 - if (!$revision) { 113 - return array(); 114 - } 115 - return $revision->getReviewers(); 116 - case self::FIELD_DIFFERENTIAL_CCS: 117 - $revision = $this->getRevision(); 118 - if (!$revision) { 119 - return array(); 120 - } 121 - return $revision->getCCPHIDs(); 122 - case self::FIELD_IS_MERGE_COMMIT: 123 - return $this->getIsMergeCommit(); 124 - case self::FIELD_PUSHER_IS_COMMITTER: 125 - $pusher_phid = $this->getHookEngine()->getViewer()->getPHID(); 126 - return ($this->getCommitterPHID() == $pusher_phid); 127 - } 128 - 129 - return parent::getHeraldField($field); 32 + public function isDiffEnormous() { 33 + $this->getDiffContent('*'); 34 + return ($this->changesets instanceof Exception); 130 35 } 131 36 132 - private function getDiffContent($type) { 37 + public function getDiffContent($type) { 133 38 if ($this->changesets === null) { 134 39 try { 135 40 $this->changesets = $this->getHookEngine()->loadChangesetsForCommit( ··· 178 83 return $result; 179 84 } 180 85 181 - private function getCommitRef() { 86 + public function getCommitRef() { 182 87 if ($this->commitRef === null) { 183 88 $this->commitRef = $this->getHookEngine()->loadCommitRefForCommit( 184 89 $this->getObject()->getRefNew()); ··· 186 91 return $this->commitRef; 187 92 } 188 93 189 - private function getAuthorPHID() { 94 + public function getAuthorPHID() { 190 95 $repository = $this->getHookEngine()->getRepository(); 191 96 $vcs = $repository->getVersionControlSystem(); 192 97 switch ($vcs) { ··· 204 109 } 205 110 } 206 111 207 - private function getCommitterPHID() { 112 + public function getCommitterPHID() { 208 113 $repository = $this->getHookEngine()->getRepository(); 209 114 $vcs = $repository->getVersionControlSystem(); 210 115 switch ($vcs) { ··· 225 130 } 226 131 } 227 132 228 - private function getAuthorRaw() { 133 + public function getAuthorRaw() { 229 134 $repository = $this->getHookEngine()->getRepository(); 230 135 $vcs = $repository->getVersionControlSystem(); 231 136 switch ($vcs) { ··· 239 144 } 240 145 } 241 146 242 - private function getCommitterRaw() { 147 + public function getCommitterRaw() { 243 148 $repository = $this->getHookEngine()->getRepository(); 244 149 $vcs = $repository->getVersionControlSystem(); 245 150 switch ($vcs) { ··· 275 180 return $this->fields; 276 181 } 277 182 278 - private function getRevision() { 183 + public function getRevision() { 279 184 if ($this->revision === false) { 280 185 $fields = $this->getCommitFields(); 281 186 $revision_id = idx($fields, 'revisionID'); ··· 293 198 return $this->revision; 294 199 } 295 200 296 - private function getIsMergeCommit() { 201 + public function getIsMergeCommit() { 297 202 $repository = $this->getHookEngine()->getRepository(); 298 203 $vcs = $repository->getVersionControlSystem(); 299 204 switch ($vcs) { ··· 313 218 } 314 219 } 315 220 316 - private function getBranches() { 221 + public function getBranches() { 317 222 return $this->getHookEngine()->loadBranches( 318 223 $this->getObject()->getRefNew()); 319 224 }
+20 -206
src/applications/herald/adapter/HeraldAdapter.php
··· 2 2 3 3 abstract class HeraldAdapter extends Phobject { 4 4 5 - const FIELD_TITLE = 'title'; 6 - const FIELD_BODY = 'body'; 7 - const FIELD_AUTHOR = 'author'; 8 - const FIELD_REVIEWER = 'reviewer'; 9 - const FIELD_COMMITTER = 'committer'; 10 - const FIELD_DIFF_FILE = 'diff-file'; 11 - const FIELD_DIFF_CONTENT = 'diff-content'; 12 - const FIELD_DIFF_ADDED_CONTENT = 'diff-added-content'; 13 - const FIELD_DIFF_REMOVED_CONTENT = 'diff-removed-content'; 14 - const FIELD_DIFF_ENORMOUS = 'diff-enormous'; 15 - const FIELD_REPOSITORY = 'repository'; 16 - const FIELD_REPOSITORY_PROJECTS = 'repository-projects'; 17 - const FIELD_AFFECTED_PACKAGE = 'affected-package'; 18 - const FIELD_AFFECTED_PACKAGE_OWNER = 'affected-package-owner'; 19 - const FIELD_AUTHOR_PROJECTS = 'authorprojects'; 20 - const FIELD_PUSHER = 'pusher'; 21 - const FIELD_PUSHER_PROJECTS = 'pusher-projects'; 22 - const FIELD_DIFFERENTIAL_REVISION = 'differential-revision'; 23 - const FIELD_DIFFERENTIAL_REVIEWERS = 'differential-reviewers'; 24 - const FIELD_DIFFERENTIAL_CCS = 'differential-ccs'; 25 - const FIELD_DIFFERENTIAL_ACCEPTED = 'differential-accepted'; 26 - const FIELD_IS_MERGE_COMMIT = 'is-merge-commit'; 27 - const FIELD_BRANCHES = 'branches'; 28 - const FIELD_AUTHOR_RAW = 'author-raw'; 29 - const FIELD_COMMITTER_RAW = 'committer-raw'; 30 - const FIELD_PUSHER_IS_COMMITTER = 'pusher-is-committer'; 31 - 32 5 const CONDITION_CONTAINS = 'contains'; 33 6 const CONDITION_NOT_CONTAINS = '!contains'; 34 7 const CONDITION_IS = 'is'; ··· 178 151 179 152 abstract public function getHeraldName(); 180 153 181 - public function getHeraldField($field_name) { 182 - $impl = $this->getFieldImplementation($field_name); 183 - if ($impl) { 184 - return $impl->getHeraldFieldValue($this->getObject()); 185 - } 186 - 187 - throw new Exception(pht("Unknown field '%s'!", $field_name)); 154 + public function getHeraldField($field_key) { 155 + return $this->requireFieldImplementation($field_key) 156 + ->getHeraldFieldValue($this->getObject()); 188 157 } 189 158 190 159 public function applyHeraldEffects(array $effects) { ··· 358 327 } 359 328 360 329 public function getFieldNameMap() { 361 - $map = mpull($this->getFieldImplementationMap(), 'getHeraldFieldName'); 362 - 363 - return $map + array( 364 - self::FIELD_TITLE => pht('Title'), 365 - self::FIELD_BODY => pht('Body'), 366 - self::FIELD_AUTHOR => pht('Author'), 367 - self::FIELD_COMMITTER => pht('Committer'), 368 - self::FIELD_REVIEWER => pht('Reviewer'), 369 - self::FIELD_DIFF_FILE => pht('Any changed filename'), 370 - self::FIELD_DIFF_CONTENT => pht('Any changed file content'), 371 - self::FIELD_DIFF_ADDED_CONTENT => pht('Any added file content'), 372 - self::FIELD_DIFF_REMOVED_CONTENT => pht('Any removed file content'), 373 - self::FIELD_DIFF_ENORMOUS => pht('Change is enormous'), 374 - self::FIELD_REPOSITORY => pht('Repository'), 375 - self::FIELD_REPOSITORY_PROJECTS => pht('Repository\'s projects'), 376 - self::FIELD_AFFECTED_PACKAGE => pht('Any affected package'), 377 - self::FIELD_AFFECTED_PACKAGE_OWNER => 378 - pht("Any affected package's owner"), 379 - self::FIELD_AUTHOR_PROJECTS => pht("Author's projects"), 380 - self::FIELD_PUSHER => pht('Pusher'), 381 - self::FIELD_PUSHER_PROJECTS => pht("Pusher's projects"), 382 - self::FIELD_DIFFERENTIAL_REVISION => pht('Differential revision'), 383 - self::FIELD_DIFFERENTIAL_REVIEWERS => pht('Differential reviewers'), 384 - self::FIELD_DIFFERENTIAL_CCS => pht('Differential CCs'), 385 - self::FIELD_DIFFERENTIAL_ACCEPTED 386 - => pht('Accepted Differential revision'), 387 - self::FIELD_IS_MERGE_COMMIT => pht('Commit is a merge'), 388 - self::FIELD_BRANCHES => pht('Commit\'s branches'), 389 - self::FIELD_AUTHOR_RAW => pht('Raw author name'), 390 - self::FIELD_COMMITTER_RAW => pht('Raw committer name'), 391 - self::FIELD_PUSHER_IS_COMMITTER => pht('Pusher same as committer'), 392 - ); 330 + return mpull($this->getFieldImplementationMap(), 'getHeraldFieldName'); 393 331 } 394 332 395 333 ··· 425 363 } 426 364 427 365 public function getConditionsForField($field) { 428 - $impl = $this->getFieldImplementation($field); 429 - if ($impl) { 430 - return $impl->getHeraldFieldConditions(); 431 - } 366 + return $this->requireFieldImplementation($field) 367 + ->getHeraldFieldConditions(); 368 + } 432 369 433 - switch ($field) { 434 - case self::FIELD_TITLE: 435 - case self::FIELD_BODY: 436 - case self::FIELD_COMMITTER_RAW: 437 - case self::FIELD_AUTHOR_RAW: 438 - return array( 439 - self::CONDITION_CONTAINS, 440 - self::CONDITION_NOT_CONTAINS, 441 - self::CONDITION_IS, 442 - self::CONDITION_IS_NOT, 443 - self::CONDITION_REGEXP, 444 - ); 445 - case self::FIELD_REVIEWER: 446 - case self::FIELD_PUSHER: 447 - return array( 448 - self::CONDITION_IS_ANY, 449 - self::CONDITION_IS_NOT_ANY, 450 - ); 451 - case self::FIELD_REPOSITORY: 452 - case self::FIELD_AUTHOR: 453 - case self::FIELD_COMMITTER: 454 - return array( 455 - self::CONDITION_IS_ANY, 456 - self::CONDITION_IS_NOT_ANY, 457 - self::CONDITION_EXISTS, 458 - self::CONDITION_NOT_EXISTS, 459 - ); 460 - case self::FIELD_AUTHOR_PROJECTS: 461 - case self::FIELD_AFFECTED_PACKAGE: 462 - case self::FIELD_AFFECTED_PACKAGE_OWNER: 463 - case self::FIELD_PUSHER_PROJECTS: 464 - case self::FIELD_REPOSITORY_PROJECTS: 465 - return array( 466 - self::CONDITION_INCLUDE_ALL, 467 - self::CONDITION_INCLUDE_ANY, 468 - self::CONDITION_INCLUDE_NONE, 469 - self::CONDITION_EXISTS, 470 - self::CONDITION_NOT_EXISTS, 471 - ); 472 - case self::FIELD_DIFF_FILE: 473 - case self::FIELD_BRANCHES: 474 - return array( 475 - self::CONDITION_CONTAINS, 476 - self::CONDITION_REGEXP, 477 - ); 478 - case self::FIELD_DIFF_CONTENT: 479 - case self::FIELD_DIFF_ADDED_CONTENT: 480 - case self::FIELD_DIFF_REMOVED_CONTENT: 481 - return array( 482 - self::CONDITION_CONTAINS, 483 - self::CONDITION_REGEXP, 484 - self::CONDITION_REGEXP_PAIR, 485 - ); 486 - case self::FIELD_DIFFERENTIAL_REVIEWERS: 487 - return array( 488 - self::CONDITION_EXISTS, 489 - self::CONDITION_NOT_EXISTS, 490 - self::CONDITION_INCLUDE_ALL, 491 - self::CONDITION_INCLUDE_ANY, 492 - self::CONDITION_INCLUDE_NONE, 493 - ); 494 - case self::FIELD_DIFFERENTIAL_CCS: 495 - return array( 496 - self::CONDITION_INCLUDE_ALL, 497 - self::CONDITION_INCLUDE_ANY, 498 - self::CONDITION_INCLUDE_NONE, 499 - ); 500 - case self::FIELD_DIFFERENTIAL_REVISION: 501 - case self::FIELD_DIFFERENTIAL_ACCEPTED: 502 - return array( 503 - self::CONDITION_EXISTS, 504 - self::CONDITION_NOT_EXISTS, 505 - ); 506 - case self::FIELD_IS_MERGE_COMMIT: 507 - case self::FIELD_DIFF_ENORMOUS: 508 - case self::FIELD_PUSHER_IS_COMMITTER: 509 - return array( 510 - self::CONDITION_IS_TRUE, 511 - self::CONDITION_IS_FALSE, 512 - ); 513 - default: 514 - throw new Exception( 515 - pht( 516 - "This adapter does not define conditions for field '%s'!", 517 - $field)); 370 + private function requireFieldImplementation($field_key) { 371 + $field = $this->getFieldImplementation($field_key); 372 + 373 + if (!$field) { 374 + throw new Exception( 375 + pht( 376 + 'No field with key "%s" is available to Herald adapter "%s".', 377 + $field_key, 378 + get_class($this))); 518 379 } 380 + 381 + return $field; 519 382 } 520 383 521 384 public function doesConditionMatch( ··· 884 747 885 748 886 749 public function getValueTypeForFieldAndCondition($field, $condition) { 887 - $impl = $this->getFieldImplementation($field); 888 - if ($impl) { 889 - return $impl->getHeraldFieldValueType($condition); 890 - } 891 - 892 - switch ($condition) { 893 - case self::CONDITION_CONTAINS: 894 - case self::CONDITION_NOT_CONTAINS: 895 - case self::CONDITION_REGEXP: 896 - case self::CONDITION_REGEXP_PAIR: 897 - return self::VALUE_TEXT; 898 - case self::CONDITION_IS: 899 - case self::CONDITION_IS_NOT: 900 - return self::VALUE_TEXT; 901 - case self::CONDITION_IS_ANY: 902 - case self::CONDITION_IS_NOT_ANY: 903 - switch ($field) { 904 - case self::FIELD_REPOSITORY: 905 - return self::VALUE_REPOSITORY; 906 - default: 907 - return self::VALUE_USER; 908 - } 909 - break; 910 - case self::CONDITION_INCLUDE_ALL: 911 - case self::CONDITION_INCLUDE_ANY: 912 - case self::CONDITION_INCLUDE_NONE: 913 - switch ($field) { 914 - case self::FIELD_REPOSITORY: 915 - return self::VALUE_REPOSITORY; 916 - case self::FIELD_AFFECTED_PACKAGE: 917 - return self::VALUE_OWNERS_PACKAGE; 918 - case self::FIELD_AUTHOR_PROJECTS: 919 - case self::FIELD_PUSHER_PROJECTS: 920 - case self::FIELD_REPOSITORY_PROJECTS: 921 - return self::VALUE_PROJECT; 922 - default: 923 - return self::VALUE_USER; 924 - } 925 - break; 926 - case self::CONDITION_IS_ME: 927 - case self::CONDITION_IS_NOT_ME: 928 - case self::CONDITION_EXISTS: 929 - case self::CONDITION_NOT_EXISTS: 930 - case self::CONDITION_UNCONDITIONALLY: 931 - case self::CONDITION_NEVER: 932 - case self::CONDITION_IS_TRUE: 933 - case self::CONDITION_IS_FALSE: 934 - return self::VALUE_NONE; 935 - default: 936 - throw new Exception(pht("Unknown condition '%s'.", $condition)); 937 - } 750 + return $this->requireFieldImplementation($field) 751 + ->getHeraldFieldValueType($condition); 938 752 } 939 753 940 754 public function getValueTypeForAction($action, $rule_type) {