mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 19:40:55 +01:00
Modernize all Herald DifferentialDiff fields
Summary: Ref T8726. This deals with all the Differential diff fields, same deal as previous changes. Test Plan: - Wrote a rule with every field. - Migrated it. - Saw the same rule working. - Rigged the hell out of transcripts (diffs normally do not generate transcripts, because the only action is "block" and they don't exist yet when Herald runs). - Verified that all fields looked sensible in the transcript. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T8726 Differential Revision: https://secure.phabricator.com/D13590
This commit is contained in:
parent
ae81f86a67
commit
c013108675
13 changed files with 319 additions and 68 deletions
55
resources/sql/autopatches/20150707.herald.1.sql
Normal file
55
resources/sql/autopatches/20150707.herald.1.sql
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
UPDATE {$NAMESPACE}_herald.herald_condition c
|
||||||
|
JOIN {$NAMESPACE}_herald.herald_rule r
|
||||||
|
ON c.ruleID = r.id
|
||||||
|
SET c.fieldName = 'differential.diff.affected'
|
||||||
|
WHERE r.contentType = 'differential.diff'
|
||||||
|
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 = 'differential.diff.author'
|
||||||
|
WHERE r.contentType = 'differential.diff'
|
||||||
|
AND c.fieldName = 'author';
|
||||||
|
|
||||||
|
UPDATE {$NAMESPACE}_herald.herald_condition c
|
||||||
|
JOIN {$NAMESPACE}_herald.herald_rule r
|
||||||
|
ON c.ruleID = r.id
|
||||||
|
SET c.fieldName = 'differential.diff.author.projects'
|
||||||
|
WHERE r.contentType = 'differential.diff'
|
||||||
|
AND c.fieldName = 'authorprojects';
|
||||||
|
|
||||||
|
UPDATE {$NAMESPACE}_herald.herald_condition c
|
||||||
|
JOIN {$NAMESPACE}_herald.herald_rule r
|
||||||
|
ON c.ruleID = r.id
|
||||||
|
SET c.fieldName = 'differential.diff.new'
|
||||||
|
WHERE r.contentType = 'differential.diff'
|
||||||
|
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 = 'differential.diff.content'
|
||||||
|
WHERE r.contentType = 'differential.diff'
|
||||||
|
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 = 'differential.diff.old'
|
||||||
|
WHERE r.contentType = 'differential.diff'
|
||||||
|
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 = 'differential.diff.repository'
|
||||||
|
WHERE r.contentType = 'differential.diff'
|
||||||
|
AND c.fieldName = 'repository';
|
||||||
|
|
||||||
|
UPDATE {$NAMESPACE}_herald.herald_condition c
|
||||||
|
JOIN {$NAMESPACE}_herald.herald_rule r
|
||||||
|
ON c.ruleID = r.id
|
||||||
|
SET c.fieldName = 'differential.diff.repository.projects'
|
||||||
|
WHERE r.contentType = 'differential.diff'
|
||||||
|
AND c.fieldName = 'repository-projects';
|
|
@ -350,12 +350,21 @@ phutil_register_library_map(array(
|
||||||
'DifferentialDependenciesField' => 'applications/differential/customfield/DifferentialDependenciesField.php',
|
'DifferentialDependenciesField' => 'applications/differential/customfield/DifferentialDependenciesField.php',
|
||||||
'DifferentialDependsOnField' => 'applications/differential/customfield/DifferentialDependsOnField.php',
|
'DifferentialDependsOnField' => 'applications/differential/customfield/DifferentialDependsOnField.php',
|
||||||
'DifferentialDiff' => 'applications/differential/storage/DifferentialDiff.php',
|
'DifferentialDiff' => 'applications/differential/storage/DifferentialDiff.php',
|
||||||
|
'DifferentialDiffAffectedFilesHeraldField' => 'applications/differential/herald/DifferentialDiffAffectedFilesHeraldField.php',
|
||||||
|
'DifferentialDiffAuthorHeraldField' => 'applications/differential/herald/DifferentialDiffAuthorHeraldField.php',
|
||||||
|
'DifferentialDiffAuthorProjectsHeraldField' => 'applications/differential/herald/DifferentialDiffAuthorProjectsHeraldField.php',
|
||||||
|
'DifferentialDiffContentAddedHeraldField' => 'applications/differential/herald/DifferentialDiffContentAddedHeraldField.php',
|
||||||
|
'DifferentialDiffContentHeraldField' => 'applications/differential/herald/DifferentialDiffContentHeraldField.php',
|
||||||
|
'DifferentialDiffContentRemovedHeraldField' => 'applications/differential/herald/DifferentialDiffContentRemovedHeraldField.php',
|
||||||
'DifferentialDiffCreateController' => 'applications/differential/controller/DifferentialDiffCreateController.php',
|
'DifferentialDiffCreateController' => 'applications/differential/controller/DifferentialDiffCreateController.php',
|
||||||
'DifferentialDiffEditor' => 'applications/differential/editor/DifferentialDiffEditor.php',
|
'DifferentialDiffEditor' => 'applications/differential/editor/DifferentialDiffEditor.php',
|
||||||
|
'DifferentialDiffHeraldField' => 'applications/differential/herald/DifferentialDiffHeraldField.php',
|
||||||
'DifferentialDiffInlineCommentQuery' => 'applications/differential/query/DifferentialDiffInlineCommentQuery.php',
|
'DifferentialDiffInlineCommentQuery' => 'applications/differential/query/DifferentialDiffInlineCommentQuery.php',
|
||||||
'DifferentialDiffPHIDType' => 'applications/differential/phid/DifferentialDiffPHIDType.php',
|
'DifferentialDiffPHIDType' => 'applications/differential/phid/DifferentialDiffPHIDType.php',
|
||||||
'DifferentialDiffProperty' => 'applications/differential/storage/DifferentialDiffProperty.php',
|
'DifferentialDiffProperty' => 'applications/differential/storage/DifferentialDiffProperty.php',
|
||||||
'DifferentialDiffQuery' => 'applications/differential/query/DifferentialDiffQuery.php',
|
'DifferentialDiffQuery' => 'applications/differential/query/DifferentialDiffQuery.php',
|
||||||
|
'DifferentialDiffRepositoryHeraldField' => 'applications/differential/herald/DifferentialDiffRepositoryHeraldField.php',
|
||||||
|
'DifferentialDiffRepositoryProjectsHeraldField' => 'applications/differential/herald/DifferentialDiffRepositoryProjectsHeraldField.php',
|
||||||
'DifferentialDiffTableOfContentsView' => 'applications/differential/view/DifferentialDiffTableOfContentsView.php',
|
'DifferentialDiffTableOfContentsView' => 'applications/differential/view/DifferentialDiffTableOfContentsView.php',
|
||||||
'DifferentialDiffTestCase' => 'applications/differential/storage/__tests__/DifferentialDiffTestCase.php',
|
'DifferentialDiffTestCase' => 'applications/differential/storage/__tests__/DifferentialDiffTestCase.php',
|
||||||
'DifferentialDiffTransaction' => 'applications/differential/storage/DifferentialDiffTransaction.php',
|
'DifferentialDiffTransaction' => 'applications/differential/storage/DifferentialDiffTransaction.php',
|
||||||
|
@ -960,8 +969,8 @@ phutil_register_library_map(array(
|
||||||
'HeraldController' => 'applications/herald/controller/HeraldController.php',
|
'HeraldController' => 'applications/herald/controller/HeraldController.php',
|
||||||
'HeraldCustomAction' => 'applications/herald/extension/HeraldCustomAction.php',
|
'HeraldCustomAction' => 'applications/herald/extension/HeraldCustomAction.php',
|
||||||
'HeraldDAO' => 'applications/herald/storage/HeraldDAO.php',
|
'HeraldDAO' => 'applications/herald/storage/HeraldDAO.php',
|
||||||
'HeraldDifferentialAdapter' => 'applications/herald/adapter/HeraldDifferentialAdapter.php',
|
'HeraldDifferentialAdapter' => 'applications/differential/herald/HeraldDifferentialAdapter.php',
|
||||||
'HeraldDifferentialDiffAdapter' => 'applications/herald/adapter/HeraldDifferentialDiffAdapter.php',
|
'HeraldDifferentialDiffAdapter' => 'applications/differential/herald/HeraldDifferentialDiffAdapter.php',
|
||||||
'HeraldDifferentialRevisionAdapter' => 'applications/herald/adapter/HeraldDifferentialRevisionAdapter.php',
|
'HeraldDifferentialRevisionAdapter' => 'applications/herald/adapter/HeraldDifferentialRevisionAdapter.php',
|
||||||
'HeraldDisableController' => 'applications/herald/controller/HeraldDisableController.php',
|
'HeraldDisableController' => 'applications/herald/controller/HeraldDisableController.php',
|
||||||
'HeraldEffect' => 'applications/herald/engine/HeraldEffect.php',
|
'HeraldEffect' => 'applications/herald/engine/HeraldEffect.php',
|
||||||
|
@ -3790,12 +3799,21 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorApplicationTransactionInterface',
|
'PhabricatorApplicationTransactionInterface',
|
||||||
'PhabricatorDestructibleInterface',
|
'PhabricatorDestructibleInterface',
|
||||||
),
|
),
|
||||||
|
'DifferentialDiffAffectedFilesHeraldField' => 'DifferentialDiffHeraldField',
|
||||||
|
'DifferentialDiffAuthorHeraldField' => 'DifferentialDiffHeraldField',
|
||||||
|
'DifferentialDiffAuthorProjectsHeraldField' => 'DifferentialDiffHeraldField',
|
||||||
|
'DifferentialDiffContentAddedHeraldField' => 'DifferentialDiffHeraldField',
|
||||||
|
'DifferentialDiffContentHeraldField' => 'DifferentialDiffHeraldField',
|
||||||
|
'DifferentialDiffContentRemovedHeraldField' => 'DifferentialDiffHeraldField',
|
||||||
'DifferentialDiffCreateController' => 'DifferentialController',
|
'DifferentialDiffCreateController' => 'DifferentialController',
|
||||||
'DifferentialDiffEditor' => 'PhabricatorApplicationTransactionEditor',
|
'DifferentialDiffEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||||
|
'DifferentialDiffHeraldField' => 'HeraldField',
|
||||||
'DifferentialDiffInlineCommentQuery' => 'PhabricatorDiffInlineCommentQuery',
|
'DifferentialDiffInlineCommentQuery' => 'PhabricatorDiffInlineCommentQuery',
|
||||||
'DifferentialDiffPHIDType' => 'PhabricatorPHIDType',
|
'DifferentialDiffPHIDType' => 'PhabricatorPHIDType',
|
||||||
'DifferentialDiffProperty' => 'DifferentialDAO',
|
'DifferentialDiffProperty' => 'DifferentialDAO',
|
||||||
'DifferentialDiffQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
'DifferentialDiffQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
|
'DifferentialDiffRepositoryHeraldField' => 'DifferentialDiffHeraldField',
|
||||||
|
'DifferentialDiffRepositoryProjectsHeraldField' => 'DifferentialDiffHeraldField',
|
||||||
'DifferentialDiffTableOfContentsView' => 'AphrontView',
|
'DifferentialDiffTableOfContentsView' => 'AphrontView',
|
||||||
'DifferentialDiffTestCase' => 'PhutilTestCase',
|
'DifferentialDiffTestCase' => 'PhutilTestCase',
|
||||||
'DifferentialDiffTransaction' => 'PhabricatorApplicationTransaction',
|
'DifferentialDiffTransaction' => 'PhabricatorApplicationTransaction',
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class DifferentialDiffAffectedFilesHeraldField
|
||||||
|
extends DifferentialDiffHeraldField {
|
||||||
|
|
||||||
|
const FIELDCONST = 'differential.diff.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) {
|
||||||
|
switch ($condition) {
|
||||||
|
case HeraldAdapter::CONDITION_EXISTS:
|
||||||
|
case HeraldAdapter::CONDITION_NOT_EXISTS:
|
||||||
|
return HeraldAdapter::VALUE_NONE;
|
||||||
|
default:
|
||||||
|
return HeraldAdapter::VALUE_TEXT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class DifferentialDiffAuthorHeraldField
|
||||||
|
extends DifferentialDiffHeraldField {
|
||||||
|
|
||||||
|
const FIELDCONST = 'differential.diff.author';
|
||||||
|
|
||||||
|
public function getHeraldFieldName() {
|
||||||
|
return pht('Author');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHeraldFieldValue($object) {
|
||||||
|
return $object->getAuthorPHID();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getHeraldFieldStandardConditions() {
|
||||||
|
return self::STANDARD_PHID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHeraldFieldValueType($condition) {
|
||||||
|
return HeraldAdapter::VALUE_USER;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class DifferentialDiffAuthorProjectsHeraldField
|
||||||
|
extends DifferentialDiffHeraldField {
|
||||||
|
|
||||||
|
const FIELDCONST = 'differential.diff.author.projects';
|
||||||
|
|
||||||
|
public function getHeraldFieldName() {
|
||||||
|
return pht("Author's projects");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHeraldFieldValue($object) {
|
||||||
|
return PhabricatorEdgeQuery::loadDestinationPHIDs(
|
||||||
|
$object->getAuthorPHID(),
|
||||||
|
PhabricatorProjectMemberOfProjectEdgeType::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,24 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class DifferentialDiffContentAddedHeraldField
|
||||||
|
extends DifferentialDiffHeraldField {
|
||||||
|
|
||||||
|
const FIELDCONST = 'differential.diff.new';
|
||||||
|
|
||||||
|
public function getHeraldFieldName() {
|
||||||
|
return pht('Added file content');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHeraldFieldValue($object) {
|
||||||
|
return $this->getAdapter()->loadAddedContentDictionary();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getHeraldFieldStandardConditions() {
|
||||||
|
return self::STANDARD_TEXT_MAP;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHeraldFieldValueType($condition) {
|
||||||
|
return HeraldAdapter::VALUE_TEXT;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class DifferentialDiffContentHeraldField
|
||||||
|
extends DifferentialDiffHeraldField {
|
||||||
|
|
||||||
|
const FIELDCONST = 'differential.diff.content';
|
||||||
|
|
||||||
|
public function getHeraldFieldName() {
|
||||||
|
return pht('Changed file content');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHeraldFieldValue($object) {
|
||||||
|
return $this->getAdapter()->loadContentDictionary();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getHeraldFieldStandardConditions() {
|
||||||
|
return self::STANDARD_TEXT_MAP;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHeraldFieldValueType($condition) {
|
||||||
|
return HeraldAdapter::VALUE_TEXT;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class DifferentialDiffContentRemovedHeraldField
|
||||||
|
extends DifferentialDiffHeraldField {
|
||||||
|
|
||||||
|
const FIELDCONST = 'differential.diff.old';
|
||||||
|
|
||||||
|
public function getHeraldFieldName() {
|
||||||
|
return pht('Removed file content');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHeraldFieldValue($object) {
|
||||||
|
return $this->getAdapter()->loadRemovedContentDictionary();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getHeraldFieldStandardConditions() {
|
||||||
|
return self::STANDARD_TEXT_MAP;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHeraldFieldValueType($condition) {
|
||||||
|
return HeraldAdapter::VALUE_TEXT;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
abstract class DifferentialDiffHeraldField extends HeraldField {
|
||||||
|
|
||||||
|
public function supportsObject($object) {
|
||||||
|
return ($object instanceof DifferentialDiff);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class DifferentialDiffRepositoryHeraldField
|
||||||
|
extends DifferentialDiffHeraldField {
|
||||||
|
|
||||||
|
const FIELDCONST = 'differential.diff.repository';
|
||||||
|
|
||||||
|
public function getHeraldFieldName() {
|
||||||
|
return pht('Repository');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHeraldFieldValue($object) {
|
||||||
|
$repository = $this->getAdapter()->loadRepository();
|
||||||
|
|
||||||
|
if (!$repository) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $repository->getPHID();
|
||||||
|
}
|
||||||
|
|
||||||
|
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_REPOSITORY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class DifferentialDiffRepositoryProjectsHeraldField
|
||||||
|
extends DifferentialDiffHeraldField {
|
||||||
|
|
||||||
|
const FIELDCONST = 'differential.diff.repository.projects';
|
||||||
|
|
||||||
|
public function getHeraldFieldName() {
|
||||||
|
return pht('Repository projects');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHeraldFieldValue($object) {
|
||||||
|
$repository = $this->getAdapter()->loadRepository();
|
||||||
|
if (!$repository) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
return PhabricatorEdgeQuery::loadDestinationPHIDs(
|
||||||
|
$repository->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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -25,7 +25,6 @@ abstract class HeraldDifferentialAdapter extends HeraldAdapter {
|
||||||
$repository = id(new PhabricatorRepositoryQuery())
|
$repository = id(new PhabricatorRepositoryQuery())
|
||||||
->setViewer(PhabricatorUser::getOmnipotentUser())
|
->setViewer(PhabricatorUser::getOmnipotentUser())
|
||||||
->withPHIDs(array($repository_phid))
|
->withPHIDs(array($repository_phid))
|
||||||
->needProjectPHIDs(true)
|
|
||||||
->executeOne();
|
->executeOne();
|
||||||
} else {
|
} else {
|
||||||
$repository = null;
|
$repository = null;
|
||||||
|
@ -38,7 +37,7 @@ abstract class HeraldDifferentialAdapter extends HeraldAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function loadAffectedPaths() {
|
public function loadAffectedPaths() {
|
||||||
$changesets = $this->loadChangesets();
|
$changesets = $this->loadChangesets();
|
||||||
|
|
||||||
$paths = array();
|
$paths = array();
|
||||||
|
@ -62,18 +61,18 @@ abstract class HeraldDifferentialAdapter extends HeraldAdapter {
|
||||||
return $changeset->getAbsoluteRepositoryPath($repository, $diff);
|
return $changeset->getAbsoluteRepositoryPath($repository, $diff);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function loadContentDictionary() {
|
public function loadContentDictionary() {
|
||||||
$add_lines = DifferentialHunk::FLAG_LINES_ADDED;
|
$add_lines = DifferentialHunk::FLAG_LINES_ADDED;
|
||||||
$rem_lines = DifferentialHunk::FLAG_LINES_REMOVED;
|
$rem_lines = DifferentialHunk::FLAG_LINES_REMOVED;
|
||||||
$mask = ($add_lines | $rem_lines);
|
$mask = ($add_lines | $rem_lines);
|
||||||
return $this->loadContentWithMask($mask);
|
return $this->loadContentWithMask($mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function loadAddedContentDictionary() {
|
public function loadAddedContentDictionary() {
|
||||||
return $this->loadContentWithMask(DifferentialHunk::FLAG_LINES_ADDED);
|
return $this->loadContentWithMask(DifferentialHunk::FLAG_LINES_ADDED);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function loadRemovedContentDictionary() {
|
public function loadRemovedContentDictionary() {
|
||||||
return $this->loadContentWithMask(DifferentialHunk::FLAG_LINES_REMOVED);
|
return $this->loadContentWithMask(DifferentialHunk::FLAG_LINES_REMOVED);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,31 +53,12 @@ final class HeraldDifferentialDiffAdapter extends HeraldDifferentialAdapter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFields() {
|
|
||||||
return array_merge(
|
|
||||||
array(
|
|
||||||
self::FIELD_AUTHOR,
|
|
||||||
self::FIELD_AUTHOR_PROJECTS,
|
|
||||||
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,
|
|
||||||
),
|
|
||||||
parent::getFields());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getRepetitionOptions() {
|
public function getRepetitionOptions() {
|
||||||
return array(
|
return array(
|
||||||
HeraldRepetitionPolicyConfig::FIRST,
|
HeraldRepetitionPolicyConfig::FIRST,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPHID() {
|
|
||||||
return $this->getObject()->getPHID();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getHeraldName() {
|
public function getHeraldName() {
|
||||||
return pht('New Diff');
|
return pht('New Diff');
|
||||||
}
|
}
|
||||||
|
@ -88,48 +69,6 @@ final class HeraldDifferentialDiffAdapter extends HeraldDifferentialAdapter {
|
||||||
) + parent::getActionNameMap($rule_type);
|
) + parent::getActionNameMap($rule_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHeraldField($field) {
|
|
||||||
switch ($field) {
|
|
||||||
case self::FIELD_AUTHOR:
|
|
||||||
return $this->getObject()->getAuthorPHID();
|
|
||||||
break;
|
|
||||||
case self::FIELD_AUTHOR_PROJECTS:
|
|
||||||
$author_phid = $this->getHeraldField(self::FIELD_AUTHOR);
|
|
||||||
if (!$author_phid) {
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
$projects = id(new PhabricatorProjectQuery())
|
|
||||||
->setViewer(PhabricatorUser::getOmnipotentUser())
|
|
||||||
->withMemberPHIDs(array($author_phid))
|
|
||||||
->execute();
|
|
||||||
|
|
||||||
return mpull($projects, 'getPHID');
|
|
||||||
case self::FIELD_DIFF_FILE:
|
|
||||||
return $this->loadAffectedPaths();
|
|
||||||
case self::FIELD_REPOSITORY:
|
|
||||||
$repository = $this->loadRepository();
|
|
||||||
if (!$repository) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return $repository->getPHID();
|
|
||||||
case self::FIELD_REPOSITORY_PROJECTS:
|
|
||||||
$repository = $this->loadRepository();
|
|
||||||
if (!$repository) {
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
return $repository->getProjectPHIDs();
|
|
||||||
case self::FIELD_DIFF_CONTENT:
|
|
||||||
return $this->loadContentDictionary();
|
|
||||||
case self::FIELD_DIFF_ADDED_CONTENT:
|
|
||||||
return $this->loadAddedContentDictionary();
|
|
||||||
case self::FIELD_DIFF_REMOVED_CONTENT:
|
|
||||||
return $this->loadRemovedContentDictionary();
|
|
||||||
}
|
|
||||||
|
|
||||||
return parent::getHeraldField($field);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getActions($rule_type) {
|
public function getActions($rule_type) {
|
||||||
switch ($rule_type) {
|
switch ($rule_type) {
|
||||||
case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL:
|
case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL:
|
Loading…
Reference in a new issue