mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-18 17:58:37 +01:00
Modularize all Diffusion commit Herald fields
Summary: Ref T8726. Test Plan: Created a giant rule with every commit field: {F594686} Ran the upgrade, got the same rule with new fields: {F594688} Used "Test Console" to run transcripts, saw all the fields populate correctly. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T8726 Differential Revision: https://secure.phabricator.com/D13567
This commit is contained in:
parent
346221648d
commit
98ac0a022c
27 changed files with 819 additions and 162 deletions
133
resources/sql/autopatches/20150706.herald.1.sql
Normal file
133
resources/sql/autopatches/20150706.herald.1.sql
Normal file
|
@ -0,0 +1,133 @@
|
|||
UPDATE {$NAMESPACE}_herald.herald_condition
|
||||
SET fieldName = 'diffusion.commit.autoclose'
|
||||
WHERE fieldName = 'repository-autoclose-branch';
|
||||
|
||||
UPDATE {$NAMESPACE}_herald.herald_condition
|
||||
SET fieldName = 'diffusion.commit.package.audit'
|
||||
WHERE fieldName = 'need-audit-for-package';
|
||||
|
||||
UPDATE {$NAMESPACE}_herald.herald_condition c
|
||||
JOIN {$NAMESPACE}_herald.herald_rule r
|
||||
ON c.ruleID = r.id
|
||||
SET c.fieldName = 'diffusion.commit.affected'
|
||||
WHERE r.contentType = 'commit'
|
||||
AND c.fieldName = 'diff-file';
|
||||
|
||||
UPDATE {$NAMESPACE}_herald.herald_condition c
|
||||
JOIN {$NAMESPACE}_herald.herald_rule r
|
||||
ON c.ruleID = r.id
|
||||
SET c.fieldName = 'diffusion.commit.author'
|
||||
WHERE r.contentType = 'commit'
|
||||
AND c.fieldName = 'author';
|
||||
|
||||
UPDATE {$NAMESPACE}_herald.herald_condition c
|
||||
JOIN {$NAMESPACE}_herald.herald_rule r
|
||||
ON c.ruleID = r.id
|
||||
SET c.fieldName = 'diffusion.commit.branches'
|
||||
WHERE r.contentType = 'commit'
|
||||
AND c.fieldName = 'branches';
|
||||
|
||||
UPDATE {$NAMESPACE}_herald.herald_condition c
|
||||
JOIN {$NAMESPACE}_herald.herald_rule r
|
||||
ON c.ruleID = r.id
|
||||
SET c.fieldName = 'diffusion.commit.committer'
|
||||
WHERE r.contentType = 'commit'
|
||||
AND c.fieldName = 'committer';
|
||||
|
||||
UPDATE {$NAMESPACE}_herald.herald_condition c
|
||||
JOIN {$NAMESPACE}_herald.herald_rule r
|
||||
ON c.ruleID = r.id
|
||||
SET c.fieldName = 'diffusion.commit.diff.new'
|
||||
WHERE r.contentType = 'commit'
|
||||
AND c.fieldName = 'diff-added-content';
|
||||
|
||||
UPDATE {$NAMESPACE}_herald.herald_condition c
|
||||
JOIN {$NAMESPACE}_herald.herald_rule r
|
||||
ON c.ruleID = r.id
|
||||
SET c.fieldName = 'diffusion.commit.diff'
|
||||
WHERE r.contentType = 'commit'
|
||||
AND c.fieldName = 'diff-content';
|
||||
|
||||
UPDATE {$NAMESPACE}_herald.herald_condition c
|
||||
JOIN {$NAMESPACE}_herald.herald_rule r
|
||||
ON c.ruleID = r.id
|
||||
SET c.fieldName = 'diffusion.commit.diff.old'
|
||||
WHERE r.contentType = 'commit'
|
||||
AND c.fieldName = 'diff-removed-content';
|
||||
|
||||
UPDATE {$NAMESPACE}_herald.herald_condition c
|
||||
JOIN {$NAMESPACE}_herald.herald_rule r
|
||||
ON c.ruleID = r.id
|
||||
SET c.fieldName = 'diffusion.commit.enormous'
|
||||
WHERE r.contentType = 'commit'
|
||||
AND c.fieldName = 'diff-enormous';
|
||||
|
||||
UPDATE {$NAMESPACE}_herald.herald_condition c
|
||||
JOIN {$NAMESPACE}_herald.herald_rule r
|
||||
ON c.ruleID = r.id
|
||||
SET c.fieldName = 'diffusion.commit.message'
|
||||
WHERE r.contentType = 'commit'
|
||||
AND c.fieldName = 'body';
|
||||
|
||||
UPDATE {$NAMESPACE}_herald.herald_condition c
|
||||
JOIN {$NAMESPACE}_herald.herald_rule r
|
||||
ON c.ruleID = r.id
|
||||
SET c.fieldName = 'diffusion.commit.package'
|
||||
WHERE r.contentType = 'commit'
|
||||
AND c.fieldName = 'affected-package';
|
||||
|
||||
UPDATE {$NAMESPACE}_herald.herald_condition c
|
||||
JOIN {$NAMESPACE}_herald.herald_rule r
|
||||
ON c.ruleID = r.id
|
||||
SET c.fieldName = 'diffusion.commit.package.owners'
|
||||
WHERE r.contentType = 'commit'
|
||||
AND c.fieldName = 'affected-package-owner';
|
||||
|
||||
UPDATE {$NAMESPACE}_herald.herald_condition c
|
||||
JOIN {$NAMESPACE}_herald.herald_rule r
|
||||
ON c.ruleID = r.id
|
||||
SET c.fieldName = 'diffusion.commit.repository'
|
||||
WHERE r.contentType = 'commit'
|
||||
AND c.fieldName = 'repository';
|
||||
|
||||
UPDATE {$NAMESPACE}_herald.herald_condition c
|
||||
JOIN {$NAMESPACE}_herald.herald_rule r
|
||||
ON c.ruleID = r.id
|
||||
SET c.fieldName = 'diffusion.commit.repository.projects'
|
||||
WHERE r.contentType = 'commit'
|
||||
AND c.fieldName = 'repository-projects';
|
||||
|
||||
UPDATE {$NAMESPACE}_herald.herald_condition c
|
||||
JOIN {$NAMESPACE}_herald.herald_rule r
|
||||
ON c.ruleID = r.id
|
||||
SET c.fieldName = 'diffusion.commit.reviewer'
|
||||
WHERE r.contentType = 'commit'
|
||||
AND c.fieldName = 'reviewer';
|
||||
|
||||
UPDATE {$NAMESPACE}_herald.herald_condition c
|
||||
JOIN {$NAMESPACE}_herald.herald_rule r
|
||||
ON c.ruleID = r.id
|
||||
SET c.fieldName = 'diffusion.commit.revision.accepted'
|
||||
WHERE r.contentType = 'commit'
|
||||
AND c.fieldName = 'differential-accepted';
|
||||
|
||||
UPDATE {$NAMESPACE}_herald.herald_condition c
|
||||
JOIN {$NAMESPACE}_herald.herald_rule r
|
||||
ON c.ruleID = r.id
|
||||
SET c.fieldName = 'diffusion.commit.revision'
|
||||
WHERE r.contentType = 'commit'
|
||||
AND c.fieldName = 'differential-revision';
|
||||
|
||||
UPDATE {$NAMESPACE}_herald.herald_condition c
|
||||
JOIN {$NAMESPACE}_herald.herald_rule r
|
||||
ON c.ruleID = r.id
|
||||
SET c.fieldName = 'diffusion.commit.revision.subscribers'
|
||||
WHERE r.contentType = 'commit'
|
||||
AND c.fieldName = 'differential-ccs';
|
||||
|
||||
UPDATE {$NAMESPACE}_herald.herald_condition c
|
||||
JOIN {$NAMESPACE}_herald.herald_rule r
|
||||
ON c.ruleID = r.id
|
||||
SET c.fieldName = 'diffusion.commit.revision.reviewers'
|
||||
WHERE r.contentType = 'commit'
|
||||
AND c.fieldName = 'differential-reviewers';
|
|
@ -481,22 +481,43 @@ phutil_register_library_map(array(
|
|||
'DiffusionBrowseTableView' => 'applications/diffusion/view/DiffusionBrowseTableView.php',
|
||||
'DiffusionCachedResolveRefsQuery' => 'applications/diffusion/query/DiffusionCachedResolveRefsQuery.php',
|
||||
'DiffusionChangeController' => 'applications/diffusion/controller/DiffusionChangeController.php',
|
||||
'DiffusionCommitAffectedFilesHeraldField' => 'applications/diffusion/herald/DiffusionCommitAffectedFilesHeraldField.php',
|
||||
'DiffusionCommitAuthorHeraldField' => 'applications/diffusion/herald/DiffusionCommitAuthorHeraldField.php',
|
||||
'DiffusionCommitAutocloseHeraldField' => 'applications/diffusion/herald/DiffusionCommitAutocloseHeraldField.php',
|
||||
'DiffusionCommitBranchesController' => 'applications/diffusion/controller/DiffusionCommitBranchesController.php',
|
||||
'DiffusionCommitBranchesHeraldField' => 'applications/diffusion/herald/DiffusionCommitBranchesHeraldField.php',
|
||||
'DiffusionCommitChangeTableView' => 'applications/diffusion/view/DiffusionCommitChangeTableView.php',
|
||||
'DiffusionCommitCommitterHeraldField' => 'applications/diffusion/herald/DiffusionCommitCommitterHeraldField.php',
|
||||
'DiffusionCommitController' => 'applications/diffusion/controller/DiffusionCommitController.php',
|
||||
'DiffusionCommitDiffContentAddedHeraldField' => 'applications/diffusion/herald/DiffusionCommitDiffContentAddedHeraldField.php',
|
||||
'DiffusionCommitDiffContentHeraldField' => 'applications/diffusion/herald/DiffusionCommitDiffContentHeraldField.php',
|
||||
'DiffusionCommitDiffContentRemovedHeraldField' => 'applications/diffusion/herald/DiffusionCommitDiffContentRemovedHeraldField.php',
|
||||
'DiffusionCommitDiffEnormousHeraldField' => 'applications/diffusion/herald/DiffusionCommitDiffEnormousHeraldField.php',
|
||||
'DiffusionCommitEditController' => 'applications/diffusion/controller/DiffusionCommitEditController.php',
|
||||
'DiffusionCommitHasRevisionEdgeType' => 'applications/diffusion/edge/DiffusionCommitHasRevisionEdgeType.php',
|
||||
'DiffusionCommitHasTaskEdgeType' => 'applications/diffusion/edge/DiffusionCommitHasTaskEdgeType.php',
|
||||
'DiffusionCommitHash' => 'applications/diffusion/data/DiffusionCommitHash.php',
|
||||
'DiffusionCommitHeraldField' => 'applications/diffusion/herald/DiffusionCommitHeraldField.php',
|
||||
'DiffusionCommitHookEngine' => 'applications/diffusion/engine/DiffusionCommitHookEngine.php',
|
||||
'DiffusionCommitHookRejectException' => 'applications/diffusion/exception/DiffusionCommitHookRejectException.php',
|
||||
'DiffusionCommitMessageHeraldField' => 'applications/diffusion/herald/DiffusionCommitMessageHeraldField.php',
|
||||
'DiffusionCommitPackageAuditHeraldField' => 'applications/diffusion/herald/DiffusionCommitPackageAuditHeraldField.php',
|
||||
'DiffusionCommitPackageHeraldField' => 'applications/diffusion/herald/DiffusionCommitPackageHeraldField.php',
|
||||
'DiffusionCommitPackageOwnerHeraldField' => 'applications/diffusion/herald/DiffusionCommitPackageOwnerHeraldField.php',
|
||||
'DiffusionCommitParentsQueryConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionCommitParentsQueryConduitAPIMethod.php',
|
||||
'DiffusionCommitQuery' => 'applications/diffusion/query/DiffusionCommitQuery.php',
|
||||
'DiffusionCommitRef' => 'applications/diffusion/data/DiffusionCommitRef.php',
|
||||
'DiffusionCommitRemarkupRule' => 'applications/diffusion/remarkup/DiffusionCommitRemarkupRule.php',
|
||||
'DiffusionCommitRemarkupRuleTestCase' => 'applications/diffusion/remarkup/__tests__/DiffusionCommitRemarkupRuleTestCase.php',
|
||||
'DiffusionCommitRepositoryHeraldField' => 'applications/diffusion/herald/DiffusionCommitRepositoryHeraldField.php',
|
||||
'DiffusionCommitRepositoryProjectsHeraldField' => 'applications/diffusion/herald/DiffusionCommitRepositoryProjectsHeraldField.php',
|
||||
'DiffusionCommitRevertedByCommitEdgeType' => 'applications/diffusion/edge/DiffusionCommitRevertedByCommitEdgeType.php',
|
||||
'DiffusionCommitRevertsCommitEdgeType' => 'applications/diffusion/edge/DiffusionCommitRevertsCommitEdgeType.php',
|
||||
'DiffusionCommitReviewerHeraldField' => 'applications/diffusion/herald/DiffusionCommitReviewerHeraldField.php',
|
||||
'DiffusionCommitRevisionAcceptedHeraldField' => 'applications/diffusion/herald/DiffusionCommitRevisionAcceptedHeraldField.php',
|
||||
'DiffusionCommitRevisionHeraldField' => 'applications/diffusion/herald/DiffusionCommitRevisionHeraldField.php',
|
||||
'DiffusionCommitRevisionReviewersHeraldField' => 'applications/diffusion/herald/DiffusionCommitRevisionReviewersHeraldField.php',
|
||||
'DiffusionCommitRevisionSubscribersHeraldField' => 'applications/diffusion/herald/DiffusionCommitRevisionSubscribersHeraldField.php',
|
||||
'DiffusionCommitTagsController' => 'applications/diffusion/controller/DiffusionCommitTagsController.php',
|
||||
'DiffusionConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionConduitAPIMethod.php',
|
||||
'DiffusionController' => 'applications/diffusion/controller/DiffusionController.php',
|
||||
|
@ -933,7 +954,7 @@ phutil_register_library_map(array(
|
|||
'HeraldAlwaysField' => 'applications/herald/field/HeraldAlwaysField.php',
|
||||
'HeraldAnotherRuleField' => 'applications/herald/field/HeraldAnotherRuleField.php',
|
||||
'HeraldApplyTranscript' => 'applications/herald/storage/transcript/HeraldApplyTranscript.php',
|
||||
'HeraldCommitAdapter' => 'applications/herald/adapter/HeraldCommitAdapter.php',
|
||||
'HeraldCommitAdapter' => 'applications/diffusion/herald/HeraldCommitAdapter.php',
|
||||
'HeraldCondition' => 'applications/herald/storage/HeraldCondition.php',
|
||||
'HeraldConditionTranscript' => 'applications/herald/storage/transcript/HeraldConditionTranscript.php',
|
||||
'HeraldContentSourceField' => 'applications/herald/field/HeraldContentSourceField.php',
|
||||
|
@ -3925,22 +3946,43 @@ phutil_register_library_map(array(
|
|||
'DiffusionBrowseTableView' => 'DiffusionView',
|
||||
'DiffusionCachedResolveRefsQuery' => 'DiffusionLowLevelQuery',
|
||||
'DiffusionChangeController' => 'DiffusionController',
|
||||
'DiffusionCommitAffectedFilesHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitAuthorHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitAutocloseHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitBranchesController' => 'DiffusionController',
|
||||
'DiffusionCommitBranchesHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitChangeTableView' => 'DiffusionView',
|
||||
'DiffusionCommitCommitterHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitController' => 'DiffusionController',
|
||||
'DiffusionCommitDiffContentAddedHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitDiffContentHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitDiffContentRemovedHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitDiffEnormousHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitEditController' => 'DiffusionController',
|
||||
'DiffusionCommitHasRevisionEdgeType' => 'PhabricatorEdgeType',
|
||||
'DiffusionCommitHasTaskEdgeType' => 'PhabricatorEdgeType',
|
||||
'DiffusionCommitHash' => 'Phobject',
|
||||
'DiffusionCommitHeraldField' => 'HeraldField',
|
||||
'DiffusionCommitHookEngine' => 'Phobject',
|
||||
'DiffusionCommitHookRejectException' => 'Exception',
|
||||
'DiffusionCommitMessageHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitPackageAuditHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitPackageHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitPackageOwnerHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitParentsQueryConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod',
|
||||
'DiffusionCommitQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
'DiffusionCommitRef' => 'Phobject',
|
||||
'DiffusionCommitRemarkupRule' => 'PhabricatorObjectRemarkupRule',
|
||||
'DiffusionCommitRemarkupRuleTestCase' => 'PhabricatorTestCase',
|
||||
'DiffusionCommitRepositoryHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitRepositoryProjectsHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitRevertedByCommitEdgeType' => 'PhabricatorEdgeType',
|
||||
'DiffusionCommitRevertsCommitEdgeType' => 'PhabricatorEdgeType',
|
||||
'DiffusionCommitReviewerHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitRevisionAcceptedHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitRevisionHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitRevisionReviewersHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitRevisionSubscribersHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitTagsController' => 'DiffusionController',
|
||||
'DiffusionConduitAPIMethod' => 'ConduitAPIMethod',
|
||||
'DiffusionController' => 'PhabricatorController',
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionCommitAffectedFilesHeraldField
|
||||
extends DiffusionCommitHeraldField {
|
||||
|
||||
const FIELDCONST = 'diffusion.commit.affected';
|
||||
|
||||
public function getHeraldFieldName() {
|
||||
return pht('Affected files');
|
||||
}
|
||||
|
||||
public function getHeraldFieldValue($object) {
|
||||
return $this->getAdapter()->loadAffectedPaths();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_TEXT_LIST;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionCommitAuthorHeraldField
|
||||
extends DiffusionCommitHeraldField {
|
||||
|
||||
const FIELDCONST = 'diffusion.commit.author';
|
||||
|
||||
public function getHeraldFieldName() {
|
||||
return pht('Author');
|
||||
}
|
||||
|
||||
public function getHeraldFieldValue($object) {
|
||||
return $object->getCommitData()->getCommitDetail('authorPHID');
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_PHID_NULLABLE;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
switch ($condition) {
|
||||
case HeraldAdapter::CONDITION_EXISTS:
|
||||
case HeraldAdapter::CONDITION_NOT_EXISTS:
|
||||
return HeraldAdapter::VALUE_NONE;
|
||||
default:
|
||||
return HeraldAdapter::VALUE_USER;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionCommitAutocloseHeraldField
|
||||
extends DiffusionCommitHeraldField {
|
||||
|
||||
const FIELDCONST = 'diffusion.commit.autoclose';
|
||||
|
||||
public function getHeraldFieldName() {
|
||||
return pht('Commit is on autoclose branch');
|
||||
}
|
||||
|
||||
public function getHeraldFieldValue($object) {
|
||||
return $object->getRepository()->shouldAutocloseCommit($object);
|
||||
}
|
||||
|
||||
public function getHeraldFieldConditions() {
|
||||
return array(
|
||||
HeraldAdapter::CONDITION_UNCONDITIONALLY,
|
||||
);
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_NONE;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionCommitBranchesHeraldField
|
||||
extends DiffusionCommitHeraldField {
|
||||
|
||||
const FIELDCONST = 'diffusion.commit.branches';
|
||||
|
||||
public function getHeraldFieldName() {
|
||||
return pht('Branches');
|
||||
}
|
||||
|
||||
public function getHeraldFieldValue($object) {
|
||||
$commit = $object;
|
||||
$repository = $object->getRepository();
|
||||
|
||||
$params = array(
|
||||
'callsign' => $repository->getCallsign(),
|
||||
'contains' => $commit->getCommitIdentifier(),
|
||||
);
|
||||
|
||||
$result = id(new ConduitCall('diffusion.branchquery', $params))
|
||||
->setUser(PhabricatorUser::getOmnipotentUser())
|
||||
->execute();
|
||||
|
||||
$refs = DiffusionRepositoryRef::loadAllFromDictionaries($result);
|
||||
|
||||
return mpull($refs, 'getShortName');
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_TEXT_LIST;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionCommitCommitterHeraldField
|
||||
extends DiffusionCommitHeraldField {
|
||||
|
||||
const FIELDCONST = 'diffusion.commit.committer';
|
||||
|
||||
public function getHeraldFieldName() {
|
||||
return pht('Committer');
|
||||
}
|
||||
|
||||
public function getHeraldFieldValue($object) {
|
||||
return $object->getCommitData()->getCommitDetail('committerPHID');
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_PHID_NULLABLE;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
switch ($condition) {
|
||||
case HeraldAdapter::CONDITION_EXISTS:
|
||||
case HeraldAdapter::CONDITION_NOT_EXISTS:
|
||||
return HeraldAdapter::VALUE_NONE;
|
||||
default:
|
||||
return HeraldAdapter::VALUE_USER;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionCommitDiffContentAddedHeraldField
|
||||
extends DiffusionCommitHeraldField {
|
||||
|
||||
const FIELDCONST = 'diffusion.commit.diff.new';
|
||||
|
||||
public function getHeraldFieldName() {
|
||||
return pht('Diff content added');
|
||||
}
|
||||
|
||||
public function getHeraldFieldValue($object) {
|
||||
return $this->getAdapter()->loadDiffContent('+');
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_TEXT_MAP;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionCommitDiffContentHeraldField
|
||||
extends DiffusionCommitHeraldField {
|
||||
|
||||
const FIELDCONST = 'diffusion.commit.diff';
|
||||
|
||||
public function getHeraldFieldName() {
|
||||
return pht('Diff content');
|
||||
}
|
||||
|
||||
public function getHeraldFieldValue($object) {
|
||||
return $this->getAdapter()->loadDiffContent('*');
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_TEXT_MAP;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionCommitDiffContentRemovedHeraldField
|
||||
extends DiffusionCommitHeraldField {
|
||||
|
||||
const FIELDCONST = 'diffusion.commit.diff.old';
|
||||
|
||||
public function getHeraldFieldName() {
|
||||
return pht('Diff content removed');
|
||||
}
|
||||
|
||||
public function getHeraldFieldValue($object) {
|
||||
return $this->getAdapter()->loadDiffContent('-');
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_TEXT_MAP;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionCommitDiffEnormousHeraldField
|
||||
extends DiffusionCommitHeraldField {
|
||||
|
||||
const FIELDCONST = 'diffusion.commit.enormous';
|
||||
|
||||
public function getHeraldFieldName() {
|
||||
return pht('Change is enormous');
|
||||
}
|
||||
|
||||
public function getHeraldFieldValue($object) {
|
||||
return $this->getAdapter()->isDiffEnormous();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_BOOL;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_NONE;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
abstract class DiffusionCommitHeraldField extends HeraldField {
|
||||
|
||||
public function supportsObject($object) {
|
||||
return ($object instanceof PhabricatorRepositoryCommit);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionCommitMessageHeraldField
|
||||
extends DiffusionCommitHeraldField {
|
||||
|
||||
const FIELDCONST = 'diffusion.commit.message';
|
||||
|
||||
public function getHeraldFieldName() {
|
||||
return pht('Commit message');
|
||||
}
|
||||
|
||||
public function getHeraldFieldValue($object) {
|
||||
return $object->getCommitData()->getCommitMessage();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_TEXT;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_TEXT;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionCommitPackageAuditHeraldField
|
||||
extends DiffusionCommitHeraldField {
|
||||
|
||||
const FIELDCONST = 'diffusion.commit.package.audit';
|
||||
|
||||
public function getHeraldFieldName() {
|
||||
return pht('Affected packages that need audit');
|
||||
}
|
||||
|
||||
public function getHeraldFieldValue($object) {
|
||||
$packages = $this->getAdapter()->loadAuditNeededPackages();
|
||||
if (!$packages) {
|
||||
return array();
|
||||
}
|
||||
|
||||
return mpull($packages, 'getPHID');
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_LIST;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
switch ($condition) {
|
||||
case HeraldAdapter::CONDITION_EXISTS:
|
||||
case HeraldAdapter::CONDITION_NOT_EXISTS:
|
||||
return HeraldAdapter::VALUE_NONE;
|
||||
default:
|
||||
return HeraldAdapter::VALUE_OWNERS_PACKAGE;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionCommitPackageHeraldField
|
||||
extends DiffusionCommitHeraldField {
|
||||
|
||||
const FIELDCONST = 'diffusion.commit.package';
|
||||
|
||||
public function getHeraldFieldName() {
|
||||
return pht('Affected packages');
|
||||
}
|
||||
|
||||
public function getHeraldFieldValue($object) {
|
||||
$packages = $this->getAdapter()->loadAffectedPackages();
|
||||
return mpull($packages, 'getPHID');
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_LIST;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
switch ($condition) {
|
||||
case HeraldAdapter::CONDITION_EXISTS:
|
||||
case HeraldAdapter::CONDITION_NOT_EXISTS:
|
||||
return HeraldAdapter::VALUE_NONE;
|
||||
default:
|
||||
return HeraldAdapter::VALUE_OWNERS_PACKAGE;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionCommitPackageOwnerHeraldField
|
||||
extends DiffusionCommitHeraldField {
|
||||
|
||||
const FIELDCONST = 'diffusion.commit.package.owners';
|
||||
|
||||
public function getHeraldFieldName() {
|
||||
return pht('Affected package owners');
|
||||
}
|
||||
|
||||
public function getHeraldFieldValue($object) {
|
||||
$packages = $this->getAdapter()->loadAffectedPackages();
|
||||
if (!$packages) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$owners = PhabricatorOwnersOwner::loadAllForPackages($packages);
|
||||
|
||||
return mpull($owners, 'getUserPHID');
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_LIST;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
switch ($condition) {
|
||||
case HeraldAdapter::CONDITION_EXISTS:
|
||||
case HeraldAdapter::CONDITION_NOT_EXISTS:
|
||||
return HeraldAdapter::VALUE_NONE;
|
||||
default:
|
||||
return HeraldAdapter::VALUE_USER;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionCommitRepositoryHeraldField
|
||||
extends DiffusionCommitHeraldField {
|
||||
|
||||
const FIELDCONST = 'diffusion.commit.repository';
|
||||
|
||||
public function getHeraldFieldName() {
|
||||
return pht('Repository');
|
||||
}
|
||||
|
||||
public function getHeraldFieldValue($object) {
|
||||
return $object->getRepository()->getPHID();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_PHID;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_REPOSITORY;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionCommitRepositoryProjectsHeraldField
|
||||
extends DiffusionCommitHeraldField {
|
||||
|
||||
const FIELDCONST = 'diffusion.commit.repository.projects';
|
||||
|
||||
public function getHeraldFieldName() {
|
||||
return pht('Repository projects');
|
||||
}
|
||||
|
||||
public function getHeraldFieldValue($object) {
|
||||
return PhabricatorEdgeQuery::loadDestinationPHIDs(
|
||||
$object->getRepository()->getPHID(),
|
||||
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_LIST;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
switch ($condition) {
|
||||
case HeraldAdapter::CONDITION_EXISTS:
|
||||
case HeraldAdapter::CONDITION_NOT_EXISTS:
|
||||
return HeraldAdapter::VALUE_NONE;
|
||||
default:
|
||||
return HeraldAdapter::VALUE_PROJECT;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionCommitReviewerHeraldField
|
||||
extends DiffusionCommitHeraldField {
|
||||
|
||||
const FIELDCONST = 'diffusion.commit.reviewer';
|
||||
|
||||
public function getHeraldFieldName() {
|
||||
return pht('Reviewer');
|
||||
}
|
||||
|
||||
public function getHeraldFieldValue($object) {
|
||||
return $object->getCommitData()->getCommitDetail('reviewerPHID');
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_PHID_NULLABLE;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
switch ($condition) {
|
||||
case HeraldAdapter::CONDITION_EXISTS:
|
||||
case HeraldAdapter::CONDITION_NOT_EXISTS:
|
||||
return HeraldAdapter::VALUE_NONE;
|
||||
default:
|
||||
return HeraldAdapter::VALUE_USER;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionCommitRevisionAcceptedHeraldField
|
||||
extends DiffusionCommitHeraldField {
|
||||
|
||||
const FIELDCONST = 'diffusion.commit.revision.accepted';
|
||||
|
||||
public function getHeraldFieldName() {
|
||||
return pht('Accepted Differential revision');
|
||||
}
|
||||
|
||||
public function getHeraldFieldValue($object) {
|
||||
$revision = $this->getAdapter()->loadDifferentialRevision();
|
||||
if (!$revision) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$data = $object->getCommitData();
|
||||
$status = $data->getCommitDetail(
|
||||
'precommitRevisionStatus',
|
||||
$revision->getStatus());
|
||||
|
||||
switch ($status) {
|
||||
case ArcanistDifferentialRevisionStatus::ACCEPTED:
|
||||
case ArcanistDifferentialRevisionStatus::CLOSED:
|
||||
return $revision->getPHID();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_PHID_BOOL;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_NONE;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionCommitRevisionHeraldField
|
||||
extends DiffusionCommitHeraldField {
|
||||
|
||||
const FIELDCONST = 'diffusion.commit.revision';
|
||||
|
||||
public function getHeraldFieldName() {
|
||||
return pht('Differential revision');
|
||||
}
|
||||
|
||||
public function getHeraldFieldValue($object) {
|
||||
$revision = $this->getAdapter()->loadDifferentialRevision();
|
||||
|
||||
if (!$revision) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $revision->getPHID();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_PHID_BOOL;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_NONE;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionCommitRevisionReviewersHeraldField
|
||||
extends DiffusionCommitHeraldField {
|
||||
|
||||
const FIELDCONST = 'diffusion.commit.revision.reviewers';
|
||||
|
||||
public function getHeraldFieldName() {
|
||||
return pht('Differential reviewers');
|
||||
}
|
||||
|
||||
public function getHeraldFieldValue($object) {
|
||||
$revision = $this->getAdapter()->loadDifferentialRevision();
|
||||
|
||||
if (!$revision) {
|
||||
return array();
|
||||
}
|
||||
|
||||
return $revision->getReviewers();
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_LIST;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
switch ($condition) {
|
||||
case HeraldAdapter::CONDITION_EXISTS:
|
||||
case HeraldAdapter::CONDITION_NOT_EXISTS:
|
||||
return HeraldAdapter::VALUE_NONE;
|
||||
default:
|
||||
return HeraldAdapter::VALUE_USER_OR_PROJECT;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionCommitRevisionSubscribersHeraldField
|
||||
extends DiffusionCommitHeraldField {
|
||||
|
||||
const FIELDCONST = 'diffusion.commit.revision.subscribers';
|
||||
|
||||
public function getHeraldFieldName() {
|
||||
return pht('Differential subscribers');
|
||||
}
|
||||
|
||||
public function getHeraldFieldValue($object) {
|
||||
$revision = $this->getAdapter()->loadDifferentialRevision();
|
||||
|
||||
if (!$revision) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$phid = $revision->getPHID();
|
||||
return PhabricatorSubscribersQuery::loadSubscribersForPHID($phid);
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardConditions() {
|
||||
return self::STANDARD_LIST;
|
||||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
switch ($condition) {
|
||||
case HeraldAdapter::CONDITION_EXISTS:
|
||||
case HeraldAdapter::CONDITION_NOT_EXISTS:
|
||||
return HeraldAdapter::VALUE_NONE;
|
||||
default:
|
||||
return HeraldAdapter::VALUE_USER_OR_PROJECT;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -2,9 +2,6 @@
|
|||
|
||||
final class HeraldCommitAdapter extends HeraldAdapter {
|
||||
|
||||
const FIELD_NEED_AUDIT_FOR_PACKAGE = 'need-audit-for-package';
|
||||
const FIELD_REPOSITORY_AUTOCLOSE_BRANCH = 'repository-autoclose-branch';
|
||||
|
||||
protected $diff;
|
||||
protected $revision;
|
||||
|
||||
|
@ -86,57 +83,6 @@ final class HeraldCommitAdapter extends HeraldAdapter {
|
|||
return pht('This rule can trigger for **repositories** and **projects**.');
|
||||
}
|
||||
|
||||
public function getFieldNameMap() {
|
||||
return array(
|
||||
self::FIELD_NEED_AUDIT_FOR_PACKAGE =>
|
||||
pht('Affected packages that need audit'),
|
||||
self::FIELD_REPOSITORY_AUTOCLOSE_BRANCH
|
||||
=> pht('Commit is on closing branch'),
|
||||
) + parent::getFieldNameMap();
|
||||
}
|
||||
|
||||
public function getFields() {
|
||||
return array_merge(
|
||||
array(
|
||||
self::FIELD_BODY,
|
||||
self::FIELD_AUTHOR,
|
||||
self::FIELD_COMMITTER,
|
||||
self::FIELD_REVIEWER,
|
||||
self::FIELD_REPOSITORY,
|
||||
self::FIELD_REPOSITORY_PROJECTS,
|
||||
self::FIELD_DIFF_FILE,
|
||||
self::FIELD_DIFF_CONTENT,
|
||||
self::FIELD_DIFF_ADDED_CONTENT,
|
||||
self::FIELD_DIFF_REMOVED_CONTENT,
|
||||
self::FIELD_DIFF_ENORMOUS,
|
||||
self::FIELD_AFFECTED_PACKAGE,
|
||||
self::FIELD_AFFECTED_PACKAGE_OWNER,
|
||||
self::FIELD_NEED_AUDIT_FOR_PACKAGE,
|
||||
self::FIELD_DIFFERENTIAL_REVISION,
|
||||
self::FIELD_DIFFERENTIAL_ACCEPTED,
|
||||
self::FIELD_DIFFERENTIAL_REVIEWERS,
|
||||
self::FIELD_DIFFERENTIAL_CCS,
|
||||
self::FIELD_BRANCHES,
|
||||
self::FIELD_REPOSITORY_AUTOCLOSE_BRANCH,
|
||||
),
|
||||
parent::getFields());
|
||||
}
|
||||
|
||||
public function getConditionsForField($field) {
|
||||
switch ($field) {
|
||||
case self::FIELD_NEED_AUDIT_FOR_PACKAGE:
|
||||
return array(
|
||||
self::CONDITION_INCLUDE_ANY,
|
||||
self::CONDITION_INCLUDE_NONE,
|
||||
);
|
||||
case self::FIELD_REPOSITORY_AUTOCLOSE_BRANCH:
|
||||
return array(
|
||||
self::CONDITION_UNCONDITIONALLY,
|
||||
);
|
||||
}
|
||||
return parent::getConditionsForField($field);
|
||||
}
|
||||
|
||||
public function getActions($rule_type) {
|
||||
switch ($rule_type) {
|
||||
case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL:
|
||||
|
@ -165,17 +111,6 @@ final class HeraldCommitAdapter extends HeraldAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
public function getValueTypeForFieldAndCondition($field, $condition) {
|
||||
switch ($field) {
|
||||
case self::FIELD_DIFFERENTIAL_CCS:
|
||||
return self::VALUE_EMAIL;
|
||||
case self::FIELD_NEED_AUDIT_FOR_PACKAGE:
|
||||
return self::VALUE_OWNERS_PACKAGE;
|
||||
}
|
||||
|
||||
return parent::getValueTypeForFieldAndCondition($field, $condition);
|
||||
}
|
||||
|
||||
public static function newLegacyAdapter(
|
||||
PhabricatorRepository $repository,
|
||||
PhabricatorRepositoryCommit $commit,
|
||||
|
@ -221,10 +156,6 @@ final class HeraldCommitAdapter extends HeraldAdapter {
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getPHID() {
|
||||
return $this->commit->getPHID();
|
||||
}
|
||||
|
||||
public function getAuditMap() {
|
||||
return $this->auditMap;
|
||||
}
|
||||
|
@ -261,7 +192,7 @@ final class HeraldCommitAdapter extends HeraldAdapter {
|
|||
return $this->affectedPackages;
|
||||
}
|
||||
|
||||
public function loadAuditNeededPackage() {
|
||||
public function loadAuditNeededPackages() {
|
||||
if ($this->auditNeededPackages === null) {
|
||||
$status_arr = array(
|
||||
PhabricatorAuditStatusConstants::AUDIT_REQUIRED,
|
||||
|
@ -351,7 +282,12 @@ final class HeraldCommitAdapter extends HeraldAdapter {
|
|||
return $diff;
|
||||
}
|
||||
|
||||
private function getDiffContent($type) {
|
||||
public function isDiffEnormous() {
|
||||
$this->loadDiffContent('*');
|
||||
return ($this->commitDiff instanceof Exception);
|
||||
}
|
||||
|
||||
public function loadDiffContent($type) {
|
||||
if ($this->commitDiff === null) {
|
||||
try {
|
||||
$this->commitDiff = $this->loadCommitDiff();
|
||||
|
@ -397,94 +333,6 @@ final class HeraldCommitAdapter extends HeraldAdapter {
|
|||
return $result;
|
||||
}
|
||||
|
||||
public function getHeraldField($field) {
|
||||
$data = $this->commitData;
|
||||
switch ($field) {
|
||||
case self::FIELD_BODY:
|
||||
return $data->getCommitMessage();
|
||||
case self::FIELD_AUTHOR:
|
||||
return $data->getCommitDetail('authorPHID');
|
||||
case self::FIELD_COMMITTER:
|
||||
return $data->getCommitDetail('committerPHID');
|
||||
case self::FIELD_REVIEWER:
|
||||
return $data->getCommitDetail('reviewerPHID');
|
||||
case self::FIELD_DIFF_FILE:
|
||||
return $this->loadAffectedPaths();
|
||||
case self::FIELD_REPOSITORY:
|
||||
return $this->repository->getPHID();
|
||||
case self::FIELD_REPOSITORY_PROJECTS:
|
||||
return $this->repository->getProjectPHIDs();
|
||||
case self::FIELD_DIFF_CONTENT:
|
||||
return $this->getDiffContent('*');
|
||||
case self::FIELD_DIFF_ADDED_CONTENT:
|
||||
return $this->getDiffContent('+');
|
||||
case self::FIELD_DIFF_REMOVED_CONTENT:
|
||||
return $this->getDiffContent('-');
|
||||
case self::FIELD_DIFF_ENORMOUS:
|
||||
$this->getDiffContent('*');
|
||||
return ($this->commitDiff instanceof Exception);
|
||||
case self::FIELD_AFFECTED_PACKAGE:
|
||||
$packages = $this->loadAffectedPackages();
|
||||
return mpull($packages, 'getPHID');
|
||||
case self::FIELD_AFFECTED_PACKAGE_OWNER:
|
||||
$packages = $this->loadAffectedPackages();
|
||||
$owners = PhabricatorOwnersOwner::loadAllForPackages($packages);
|
||||
return mpull($owners, 'getUserPHID');
|
||||
case self::FIELD_NEED_AUDIT_FOR_PACKAGE:
|
||||
return $this->loadAuditNeededPackage();
|
||||
case self::FIELD_DIFFERENTIAL_REVISION:
|
||||
$revision = $this->loadDifferentialRevision();
|
||||
if (!$revision) {
|
||||
return null;
|
||||
}
|
||||
return $revision->getID();
|
||||
case self::FIELD_DIFFERENTIAL_ACCEPTED:
|
||||
$revision = $this->loadDifferentialRevision();
|
||||
if (!$revision) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$status = $data->getCommitDetail(
|
||||
'precommitRevisionStatus',
|
||||
$revision->getStatus());
|
||||
switch ($status) {
|
||||
case ArcanistDifferentialRevisionStatus::ACCEPTED:
|
||||
case ArcanistDifferentialRevisionStatus::CLOSED:
|
||||
return $revision->getPHID();
|
||||
}
|
||||
|
||||
return null;
|
||||
case self::FIELD_DIFFERENTIAL_REVIEWERS:
|
||||
$revision = $this->loadDifferentialRevision();
|
||||
if (!$revision) {
|
||||
return array();
|
||||
}
|
||||
return $revision->getReviewers();
|
||||
case self::FIELD_DIFFERENTIAL_CCS:
|
||||
$revision = $this->loadDifferentialRevision();
|
||||
if (!$revision) {
|
||||
return array();
|
||||
}
|
||||
return $revision->getCCPHIDs();
|
||||
case self::FIELD_BRANCHES:
|
||||
$params = array(
|
||||
'callsign' => $this->repository->getCallsign(),
|
||||
'contains' => $this->commit->getCommitIdentifier(),
|
||||
);
|
||||
|
||||
$result = id(new ConduitCall('diffusion.branchquery', $params))
|
||||
->setUser(PhabricatorUser::getOmnipotentUser())
|
||||
->execute();
|
||||
|
||||
$refs = DiffusionRepositoryRef::loadAllFromDictionaries($result);
|
||||
return mpull($refs, 'getShortName');
|
||||
case self::FIELD_REPOSITORY_AUTOCLOSE_BRANCH:
|
||||
return $this->repository->shouldAutocloseCommit($this->commit);
|
||||
}
|
||||
|
||||
return parent::getHeraldField($field);
|
||||
}
|
||||
|
||||
public function applyHeraldEffects(array $effects) {
|
||||
assert_instances_of($effects, 'HeraldEffect');
|
||||
|
|
@ -7,7 +7,10 @@ abstract class HeraldField extends Phobject {
|
|||
const STANDARD_LIST = 'standard.list';
|
||||
const STANDARD_BOOL = 'standard.bool';
|
||||
const STANDARD_TEXT = 'standard.text';
|
||||
const STANDARD_TEXT_LIST = 'standard.text.list';
|
||||
const STANDARD_TEXT_MAP = 'standard.text.map';
|
||||
const STANDARD_PHID = 'standard.phid';
|
||||
const STANDARD_PHID_BOOL = 'standard.phid.bool';
|
||||
const STANDARD_PHID_NULLABLE = 'standard.phid.nullable';
|
||||
|
||||
abstract public function getHeraldFieldName();
|
||||
|
@ -41,6 +44,11 @@ abstract class HeraldField extends Phobject {
|
|||
HeraldAdapter::CONDITION_IS_ANY,
|
||||
HeraldAdapter::CONDITION_IS_NOT_ANY,
|
||||
);
|
||||
case self::STANDARD_PHID_BOOL:
|
||||
return array(
|
||||
HeraldAdapter::CONDITION_EXISTS,
|
||||
HeraldAdapter::CONDITION_NOT_EXISTS,
|
||||
);
|
||||
case self::STANDARD_PHID_NULLABLE:
|
||||
return array(
|
||||
HeraldAdapter::CONDITION_IS_ANY,
|
||||
|
@ -48,6 +56,17 @@ abstract class HeraldField extends Phobject {
|
|||
HeraldAdapter::CONDITION_EXISTS,
|
||||
HeraldAdapter::CONDITION_NOT_EXISTS,
|
||||
);
|
||||
case self::STANDARD_TEXT_LIST:
|
||||
return array(
|
||||
HeraldAdapter::CONDITION_CONTAINS,
|
||||
HeraldAdapter::CONDITION_REGEXP,
|
||||
);
|
||||
case self::STANDARD_TEXT_MAP:
|
||||
return array(
|
||||
HeraldAdapter::CONDITION_CONTAINS,
|
||||
HeraldAdapter::CONDITION_REGEXP,
|
||||
HeraldAdapter::CONDITION_REGEXP_PAIR,
|
||||
);
|
||||
}
|
||||
|
||||
throw new Exception(pht('Unknown standard condition set.'));
|
||||
|
|
|
@ -18,7 +18,13 @@ final class ManiphestTaskAssigneeHeraldField
|
|||
}
|
||||
|
||||
public function getHeraldFieldValueType($condition) {
|
||||
return HeraldAdapter::VALUE_USER;
|
||||
switch ($condition) {
|
||||
case HeraldAdapter::CONDITION_EXISTS:
|
||||
case HeraldAdapter::CONDITION_NOT_EXISTS:
|
||||
return HeraldAdapter::VALUE_NONE;
|
||||
default:
|
||||
return HeraldAdapter::VALUE_USER;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ final class HeraldSubscribersField extends HeraldField {
|
|||
case HeraldAdapter::CONDITION_NOT_EXISTS:
|
||||
return HeraldAdapter::VALUE_NONE;
|
||||
default:
|
||||
return HeraldAdapter::VALUE_PROJECT;
|
||||
return HeraldAdapter::VALUE_USER_OR_PROJECT;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue