mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-26 23:40:57 +01:00
Add "Author's Packages" and "Committer's Packages" Herald rules for Commits and Hooks
Summary: Fixes T13480. Adds the remaining missing Owners package rules for Herald commit adapters. Test Plan: Created hooks which care about these fields, pushed commits, saw sensible transcript values. Maniphest Tasks: T13480 Differential Revision: https://secure.phabricator.com/D20957
This commit is contained in:
parent
6628cd2b4f
commit
c99485e8a0
9 changed files with 170 additions and 18 deletions
|
@ -737,12 +737,14 @@ phutil_register_library_map(array(
|
|||
'DiffusionCommitAuditorsHeraldField' => 'applications/diffusion/herald/DiffusionCommitAuditorsHeraldField.php',
|
||||
'DiffusionCommitAuditorsTransaction' => 'applications/diffusion/xaction/DiffusionCommitAuditorsTransaction.php',
|
||||
'DiffusionCommitAuthorHeraldField' => 'applications/diffusion/herald/DiffusionCommitAuthorHeraldField.php',
|
||||
'DiffusionCommitAuthorPackagesHeraldField' => 'applications/diffusion/herald/DiffusionCommitAuthorPackagesHeraldField.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',
|
||||
'DiffusionCommitBuildableTransaction' => 'applications/diffusion/xaction/DiffusionCommitBuildableTransaction.php',
|
||||
'DiffusionCommitCommitterHeraldField' => 'applications/diffusion/herald/DiffusionCommitCommitterHeraldField.php',
|
||||
'DiffusionCommitCommitterPackagesHeraldField' => 'applications/diffusion/herald/DiffusionCommitCommitterPackagesHeraldField.php',
|
||||
'DiffusionCommitCommitterProjectsHeraldField' => 'applications/diffusion/herald/DiffusionCommitCommitterProjectsHeraldField.php',
|
||||
'DiffusionCommitConcernTransaction' => 'applications/diffusion/xaction/DiffusionCommitConcernTransaction.php',
|
||||
'DiffusionCommitController' => 'applications/diffusion/controller/DiffusionCommitController.php',
|
||||
|
@ -908,10 +910,12 @@ phutil_register_library_map(array(
|
|||
'DiffusionPhpExternalSymbolsSource' => 'applications/diffusion/symbol/DiffusionPhpExternalSymbolsSource.php',
|
||||
'DiffusionPreCommitContentAffectedFilesHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentAffectedFilesHeraldField.php',
|
||||
'DiffusionPreCommitContentAuthorHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentAuthorHeraldField.php',
|
||||
'DiffusionPreCommitContentAuthorPackagesHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentAuthorPackagesHeraldField.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',
|
||||
'DiffusionPreCommitContentCommitterPackagesHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentCommitterPackagesHeraldField.php',
|
||||
'DiffusionPreCommitContentCommitterProjectsHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentCommitterProjectsHeraldField.php',
|
||||
'DiffusionPreCommitContentCommitterRawHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentCommitterRawHeraldField.php',
|
||||
'DiffusionPreCommitContentDiffContentAddedHeraldField' => 'applications/diffusion/herald/DiffusionPreCommitContentDiffContentAddedHeraldField.php',
|
||||
|
@ -6731,12 +6735,14 @@ phutil_register_library_map(array(
|
|||
'DiffusionCommitAuditorsHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitAuditorsTransaction' => 'DiffusionCommitTransactionType',
|
||||
'DiffusionCommitAuthorHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitAuthorPackagesHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitAuthorProjectsHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitAutocloseHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitBranchesController' => 'DiffusionController',
|
||||
'DiffusionCommitBranchesHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitBuildableTransaction' => 'DiffusionCommitTransactionType',
|
||||
'DiffusionCommitCommitterHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitCommitterPackagesHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitCommitterProjectsHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitConcernTransaction' => 'DiffusionCommitAuditTransaction',
|
||||
'DiffusionCommitController' => 'DiffusionController',
|
||||
|
@ -6905,10 +6911,12 @@ phutil_register_library_map(array(
|
|||
'DiffusionPhpExternalSymbolsSource' => 'DiffusionExternalSymbolsSource',
|
||||
'DiffusionPreCommitContentAffectedFilesHeraldField' => 'DiffusionPreCommitContentHeraldField',
|
||||
'DiffusionPreCommitContentAuthorHeraldField' => 'DiffusionPreCommitContentHeraldField',
|
||||
'DiffusionPreCommitContentAuthorPackagesHeraldField' => 'DiffusionPreCommitContentHeraldField',
|
||||
'DiffusionPreCommitContentAuthorProjectsHeraldField' => 'DiffusionPreCommitContentHeraldField',
|
||||
'DiffusionPreCommitContentAuthorRawHeraldField' => 'DiffusionPreCommitContentHeraldField',
|
||||
'DiffusionPreCommitContentBranchesHeraldField' => 'DiffusionPreCommitContentHeraldField',
|
||||
'DiffusionPreCommitContentCommitterHeraldField' => 'DiffusionPreCommitContentHeraldField',
|
||||
'DiffusionPreCommitContentCommitterPackagesHeraldField' => 'DiffusionPreCommitContentHeraldField',
|
||||
'DiffusionPreCommitContentCommitterProjectsHeraldField' => 'DiffusionPreCommitContentHeraldField',
|
||||
'DiffusionPreCommitContentCommitterRawHeraldField' => 'DiffusionPreCommitContentHeraldField',
|
||||
'DiffusionPreCommitContentDiffContentAddedHeraldField' => 'DiffusionPreCommitContentHeraldField',
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionCommitAuthorPackagesHeraldField
|
||||
extends DiffusionCommitHeraldField {
|
||||
|
||||
const FIELDCONST = 'diffusion.commit.author.packages';
|
||||
|
||||
public function getHeraldFieldName() {
|
||||
return pht("Author's packages");
|
||||
}
|
||||
|
||||
public function getHeraldFieldValue($object) {
|
||||
$adapter = $this->getAdapter();
|
||||
$viewer = $adapter->getViewer();
|
||||
|
||||
$author_phid = $adapter->getAuthorPHID();
|
||||
if (!$author_phid) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$packages = id(new PhabricatorOwnersPackageQuery())
|
||||
->setViewer($viewer)
|
||||
->withAuthorityPHIDs(array($author_phid))
|
||||
->execute();
|
||||
|
||||
return mpull($packages, 'getPHID');
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_LIST;
|
||||
}
|
||||
|
||||
protected function getDatasource() {
|
||||
return new PhabricatorOwnersPackageDatasource();
|
||||
}
|
||||
|
||||
}
|
|
@ -13,14 +13,14 @@ final class DiffusionCommitAuthorProjectsHeraldField
|
|||
$adapter = $this->getAdapter();
|
||||
$viewer = $adapter->getViewer();
|
||||
|
||||
$phid = $adapter->getAuthorPHID();
|
||||
if (!$phid) {
|
||||
$author_phid = $adapter->getAuthorPHID();
|
||||
if (!$author_phid) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$projects = id(new PhabricatorProjectQuery())
|
||||
->setViewer($viewer)
|
||||
->withMemberPHIDs(array($phid))
|
||||
->withMemberPHIDs(array($author_phid))
|
||||
->execute();
|
||||
|
||||
return mpull($projects, 'getPHID');
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionCommitCommitterPackagesHeraldField
|
||||
extends DiffusionCommitHeraldField {
|
||||
|
||||
const FIELDCONST = 'diffusion.commit.committer.packages';
|
||||
|
||||
public function getHeraldFieldName() {
|
||||
return pht("Committer's packages");
|
||||
}
|
||||
|
||||
public function getHeraldFieldValue($object) {
|
||||
$adapter = $this->getAdapter();
|
||||
$viewer = $adapter->getViewer();
|
||||
|
||||
$committer_phid = $adapter->getAuthorPHID();
|
||||
if (!$committer_phid) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$packages = id(new PhabricatorOwnersPackageQuery())
|
||||
->setViewer($viewer)
|
||||
->withAuthorityPHIDs(array($committer_phid))
|
||||
->execute();
|
||||
|
||||
return mpull($packages, 'getPHID');
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_LIST;
|
||||
}
|
||||
|
||||
protected function getDatasource() {
|
||||
return new PhabricatorOwnersPackageDatasource();
|
||||
}
|
||||
|
||||
}
|
|
@ -13,16 +13,14 @@ final class DiffusionCommitCommitterProjectsHeraldField
|
|||
$adapter = $this->getAdapter();
|
||||
$viewer = $adapter->getViewer();
|
||||
|
||||
$phid = $adapter->getCommitterPHID();
|
||||
if (!$phid) {
|
||||
$committer_phid = $adapter->getCommitterPHID();
|
||||
if (!$committer_phid) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$viewer = $adapter->getViewer();
|
||||
|
||||
$projects = id(new PhabricatorProjectQuery())
|
||||
->setViewer($viewer)
|
||||
->withMemberPHIDs(array($phid))
|
||||
->withMemberPHIDs(array($committer_phid))
|
||||
->execute();
|
||||
|
||||
return mpull($projects, 'getPHID');
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionPreCommitContentAuthorPackagesHeraldField
|
||||
extends DiffusionPreCommitContentHeraldField {
|
||||
|
||||
const FIELDCONST = 'diffusion.pre.commit.author.packages';
|
||||
|
||||
public function getHeraldFieldName() {
|
||||
return pht("Author's packages");
|
||||
}
|
||||
|
||||
public function getHeraldFieldValue($object) {
|
||||
$adapter = $this->getAdapter();
|
||||
$viewer = $adapter->getViewer();
|
||||
|
||||
$author_phid = $adapter->getAuthorPHID();
|
||||
if (!$author_phid) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$packages = id(new PhabricatorOwnersPackageQuery())
|
||||
->setViewer($viewer)
|
||||
->withAuthorityPHIDs(array($author_phid))
|
||||
->execute();
|
||||
|
||||
return mpull($packages, 'getPHID');
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_LIST;
|
||||
}
|
||||
|
||||
protected function getDatasource() {
|
||||
return new PhabricatorOwnersPackageDatasource();
|
||||
}
|
||||
|
||||
}
|
|
@ -11,17 +11,16 @@ final class DiffusionPreCommitContentAuthorProjectsHeraldField
|
|||
|
||||
public function getHeraldFieldValue($object) {
|
||||
$adapter = $this->getAdapter();
|
||||
$viewer = $adapter->getViewer();
|
||||
|
||||
$phid = $adapter->getAuthorPHID();
|
||||
if (!$phid) {
|
||||
$author_phid = $adapter->getAuthorPHID();
|
||||
if (!$author_phid) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$viewer = $adapter->getViewer();
|
||||
|
||||
$projects = id(new PhabricatorProjectQuery())
|
||||
->setViewer($viewer)
|
||||
->withMemberPHIDs(array($phid))
|
||||
->withMemberPHIDs(array($author_phid))
|
||||
->execute();
|
||||
|
||||
return mpull($projects, 'getPHID');
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionPreCommitContentCommitterPackagesHeraldField
|
||||
extends DiffusionPreCommitContentHeraldField {
|
||||
|
||||
const FIELDCONST = 'diffusion.pre.commit.committer.packages';
|
||||
|
||||
public function getHeraldFieldName() {
|
||||
return pht("Committer's packages");
|
||||
}
|
||||
|
||||
public function getHeraldFieldValue($object) {
|
||||
$adapter = $this->getAdapter();
|
||||
$viewer = $adapter->getViewer();
|
||||
|
||||
$committer_phid = $adapter->getCommitterPHID();
|
||||
if (!$committer_phid) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$packages = id(new PhabricatorOwnersPackageQuery())
|
||||
->setViewer($viewer)
|
||||
->withAuthorityPHIDs(array($committer_phid))
|
||||
->execute();
|
||||
|
||||
return mpull($packages, 'getPHID');
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_LIST;
|
||||
}
|
||||
|
||||
protected function getDatasource() {
|
||||
return new PhabricatorOwnersPackageDatasource();
|
||||
}
|
||||
|
||||
}
|
|
@ -11,17 +11,16 @@ final class DiffusionPreCommitContentCommitterProjectsHeraldField
|
|||
|
||||
public function getHeraldFieldValue($object) {
|
||||
$adapter = $this->getAdapter();
|
||||
$viewer = $adapter->getViewer();
|
||||
|
||||
$phid = $adapter->getCommitterPHID();
|
||||
if (!$phid) {
|
||||
$committer_phid = $adapter->getCommitterPHID();
|
||||
if (!$committer_phid) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$viewer = $adapter->getViewer();
|
||||
|
||||
$projects = id(new PhabricatorProjectQuery())
|
||||
->setViewer($viewer)
|
||||
->withMemberPHIDs(array($phid))
|
||||
->withMemberPHIDs(array($committer_phid))
|
||||
->execute();
|
||||
|
||||
return mpull($projects, 'getPHID');
|
||||
|
|
Loading…
Reference in a new issue