mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-02 09:58:24 +01:00
Add "Committer's projects" and "Author's projects" fields to Herald commit rules
Summary: Ref T13093. See PHI396. These are possibly somewhat niche, but reasonable to support and consistent with the existing "Pusher's projects". Also relabel "Pusher's projects" and "Project tags" for consistency and, hopefully, clarity. Test Plan: - Created new "commit" and "hook: commit content" Herald rules which run against "Author's projects" and "Committer's projects". - Test console'd the "Commit" rules. - Pushed through the "Hook" rule. - In all cases, saw fields populate appropriately. Maniphest Tasks: T13093 Differential Revision: https://secure.phabricator.com/D19145
This commit is contained in:
parent
9658249ac5
commit
80fe382e3d
9 changed files with 164 additions and 4 deletions
|
@ -652,10 +652,12 @@ phutil_register_library_map(array(
|
|||
'DiffusionCommitAuditorsHeraldField' => 'applications/diffusion/herald/DiffusionCommitAuditorsHeraldField.php',
|
||||
'DiffusionCommitAuditorsTransaction' => 'applications/diffusion/xaction/DiffusionCommitAuditorsTransaction.php',
|
||||
'DiffusionCommitAuthorHeraldField' => 'applications/diffusion/herald/DiffusionCommitAuthorHeraldField.php',
|
||||
'DiffusionCommitAuthorProjectsHeraldField' => 'applications/diffusion/herald/DiffusionCommitAuthorProjectsHeraldField.php',
|
||||
'DiffusionCommitAutocloseHeraldField' => 'applications/diffusion/herald/DiffusionCommitAutocloseHeraldField.php',
|
||||
'DiffusionCommitBranchesController' => 'applications/diffusion/controller/DiffusionCommitBranchesController.php',
|
||||
'DiffusionCommitBranchesHeraldField' => 'applications/diffusion/herald/DiffusionCommitBranchesHeraldField.php',
|
||||
'DiffusionCommitCommitterHeraldField' => 'applications/diffusion/herald/DiffusionCommitCommitterHeraldField.php',
|
||||
'DiffusionCommitCommitterProjectsHeraldField' => 'applications/diffusion/herald/DiffusionCommitCommitterProjectsHeraldField.php',
|
||||
'DiffusionCommitConcernTransaction' => 'applications/diffusion/xaction/DiffusionCommitConcernTransaction.php',
|
||||
'DiffusionCommitController' => 'applications/diffusion/controller/DiffusionCommitController.php',
|
||||
'DiffusionCommitDiffContentAddedHeraldField' => 'applications/diffusion/herald/DiffusionCommitDiffContentAddedHeraldField.php',
|
||||
|
@ -801,9 +803,11 @@ phutil_register_library_map(array(
|
|||
'DiffusionPhpExternalSymbolsSource' => 'applications/diffusion/symbol/DiffusionPhpExternalSymbolsSource.php',
|
||||
'DiffusionPreCommitContentAffectedFilesHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentAffectedFilesHeraldField.php',
|
||||
'DiffusionPreCommitContentAuthorHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentAuthorHeraldField.php',
|
||||
'DiffusionPreCommitContentAuthorProjectsHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentAuthorProjectsHeraldField.php',
|
||||
'DiffusionPreCommitContentAuthorRawHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentAuthorRawHeraldField.php',
|
||||
'DiffusionPreCommitContentBranchesHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentBranchesHeraldField.php',
|
||||
'DiffusionPreCommitContentCommitterHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentCommitterHeraldField.php',
|
||||
'DiffusionPreCommitContentCommitterProjectsHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentCommitterProjectsHeraldField.php',
|
||||
'DiffusionPreCommitContentCommitterRawHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentCommitterRawHeraldField.php',
|
||||
'DiffusionPreCommitContentDiffContentAddedHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentDiffContentAddedHeraldField.php',
|
||||
'DiffusionPreCommitContentDiffContentHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentDiffContentHeraldField.php',
|
||||
|
@ -5867,10 +5871,12 @@ phutil_register_library_map(array(
|
|||
'DiffusionCommitAuditorsHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitAuditorsTransaction' => 'DiffusionCommitTransactionType',
|
||||
'DiffusionCommitAuthorHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitAuthorProjectsHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitAutocloseHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitBranchesController' => 'DiffusionController',
|
||||
'DiffusionCommitBranchesHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitCommitterHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitCommitterProjectsHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitConcernTransaction' => 'DiffusionCommitAuditTransaction',
|
||||
'DiffusionCommitController' => 'DiffusionController',
|
||||
'DiffusionCommitDiffContentAddedHeraldField' => 'DiffusionCommitHeraldField',
|
||||
|
@ -6019,9 +6025,11 @@ phutil_register_library_map(array(
|
|||
'DiffusionPhpExternalSymbolsSource' => 'DiffusionExternalSymbolsSource',
|
||||
'DiffusionPreCommitContentAffectedFilesHeraldField' => 'DiffusionPreCommitContentHeraldField',
|
||||
'DiffusionPreCommitContentAuthorHeraldField' => 'DiffusionPreCommitContentHeraldField',
|
||||
'DiffusionPreCommitContentAuthorProjectsHeraldField' => 'DiffusionPreCommitContentHeraldField',
|
||||
'DiffusionPreCommitContentAuthorRawHeraldField' => 'DiffusionPreCommitContentHeraldField',
|
||||
'DiffusionPreCommitContentBranchesHeraldField' => 'DiffusionPreCommitContentHeraldField',
|
||||
'DiffusionPreCommitContentCommitterHeraldField' => 'DiffusionPreCommitContentHeraldField',
|
||||
'DiffusionPreCommitContentCommitterProjectsHeraldField' => 'DiffusionPreCommitContentHeraldField',
|
||||
'DiffusionPreCommitContentCommitterRawHeraldField' => 'DiffusionPreCommitContentHeraldField',
|
||||
'DiffusionPreCommitContentDiffContentAddedHeraldField' => 'DiffusionPreCommitContentHeraldField',
|
||||
'DiffusionPreCommitContentDiffContentHeraldField' => 'DiffusionPreCommitContentHeraldField',
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionCommitAuthorProjectsHeraldField
|
||||
extends DiffusionCommitHeraldField {
|
||||
|
||||
const FIELDCONST = 'diffusion.commit.author.projects';
|
||||
|
||||
public function getHeraldFieldName() {
|
||||
return pht("Author's projects");
|
||||
}
|
||||
|
||||
public function getHeraldFieldValue($object) {
|
||||
$adapter = $this->getAdapter();
|
||||
|
||||
$phid = $object->getCommitData()->getCommitDetail('authorPHID');
|
||||
if (!$phid) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$viewer = $adapter->getViewer();
|
||||
|
||||
$projects = id(new PhabricatorProjectQuery())
|
||||
->setViewer($viewer)
|
||||
->withMemberPHIDs(array($phid))
|
||||
->execute();
|
||||
|
||||
return mpull($projects, 'getPHID');
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_LIST;
|
||||
}
|
||||
|
||||
protected function getDatasource() {
|
||||
return new PhabricatorProjectDatasource();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionCommitCommitterProjectsHeraldField
|
||||
extends DiffusionCommitHeraldField {
|
||||
|
||||
const FIELDCONST = 'diffusion.commit.committer.projects';
|
||||
|
||||
public function getHeraldFieldName() {
|
||||
return pht("Committer's projects");
|
||||
}
|
||||
|
||||
public function getHeraldFieldValue($object) {
|
||||
$adapter = $this->getAdapter();
|
||||
|
||||
$phid = $object->getCommitData()->getCommitDetail('committerPHID');
|
||||
if (!$phid) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$viewer = $adapter->getViewer();
|
||||
|
||||
$projects = id(new PhabricatorProjectQuery())
|
||||
->setViewer($viewer)
|
||||
->withMemberPHIDs(array($phid))
|
||||
->execute();
|
||||
|
||||
return mpull($projects, 'getPHID');
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_LIST;
|
||||
}
|
||||
|
||||
protected function getDatasource() {
|
||||
return new PhabricatorProjectDatasource();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionPreCommitContentAuthorProjectsHeraldField
|
||||
extends DiffusionPreCommitContentHeraldField {
|
||||
|
||||
const FIELDCONST = 'diffusion.pre.commit.author.projects';
|
||||
|
||||
public function getHeraldFieldName() {
|
||||
return pht("Author's projects");
|
||||
}
|
||||
|
||||
public function getHeraldFieldValue($object) {
|
||||
$adapter = $this->getAdapter();
|
||||
|
||||
$phid = $adapter->getAuthorPHID();
|
||||
if (!$phid) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$viewer = $adapter->getViewer();
|
||||
|
||||
$projects = id(new PhabricatorProjectQuery())
|
||||
->setViewer($viewer)
|
||||
->withMemberPHIDs(array($phid))
|
||||
->execute();
|
||||
|
||||
return mpull($projects, 'getPHID');
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_LIST;
|
||||
}
|
||||
|
||||
protected function getDatasource() {
|
||||
return new PhabricatorProjectDatasource();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionPreCommitContentCommitterProjectsHeraldField
|
||||
extends DiffusionPreCommitContentHeraldField {
|
||||
|
||||
const FIELDCONST = 'diffusion.pre.commit.committer.projects';
|
||||
|
||||
public function getHeraldFieldName() {
|
||||
return pht("Committer's projects");
|
||||
}
|
||||
|
||||
public function getHeraldFieldValue($object) {
|
||||
$adapter = $this->getAdapter();
|
||||
|
||||
$phid = $adapter->getCommitterPHID();
|
||||
if (!$phid) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$viewer = $adapter->getViewer();
|
||||
|
||||
$projects = id(new PhabricatorProjectQuery())
|
||||
->setViewer($viewer)
|
||||
->withMemberPHIDs(array($phid))
|
||||
->execute();
|
||||
|
||||
return mpull($projects, 'getPHID');
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_LIST;
|
||||
}
|
||||
|
||||
protected function getDatasource() {
|
||||
return new PhabricatorProjectDatasource();
|
||||
}
|
||||
|
||||
}
|
|
@ -6,7 +6,7 @@ final class DiffusionPreCommitContentPusherProjectsHeraldField
|
|||
const FIELDCONST = 'diffusion.pre.content.pusher.projects';
|
||||
|
||||
public function getHeraldFieldName() {
|
||||
return pht('Pusher projects');
|
||||
return pht("Pusher's projects");
|
||||
}
|
||||
|
||||
public function getHeraldFieldValue($object) {
|
||||
|
|
|
@ -6,7 +6,7 @@ final class DiffusionPreCommitRefPusherProjectsHeraldField
|
|||
const FIELDCONST = 'diffusion.pre.ref.pusher.projects';
|
||||
|
||||
public function getHeraldFieldName() {
|
||||
return pht('Pusher projects');
|
||||
return pht("Pusher's projects");
|
||||
}
|
||||
|
||||
public function getHeraldFieldValue($object) {
|
||||
|
|
|
@ -16,7 +16,7 @@ final class DiffusionPreCommitRefRepositoryProjectsHeraldField
|
|||
}
|
||||
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return HeraldField::STANDARD_PHID_LIST;
|
||||
return self::STANDARD_PHID_LIST;
|
||||
}
|
||||
|
||||
protected function getDatasource() {
|
||||
|
|
|
@ -5,7 +5,7 @@ final class HeraldProjectsField extends HeraldField {
|
|||
const FIELDCONST = 'projects';
|
||||
|
||||
public function getHeraldFieldName() {
|
||||
return pht('Projects');
|
||||
return pht('Project tags');
|
||||
}
|
||||
|
||||
public function getFieldGroupKey() {
|
||||
|
|
Loading…
Add table
Reference in a new issue