mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 21:40:55 +01:00
Add an "Auditors" rule for Commits
Summary: Fixes T5889. You can't write a rule like "if no other Herald rules did anything...", but you can use this rule to check for Owners or an explicit "Auditors" field doing things. Test Plan: Using the test console, ran an "Auditors" rule against a commit with and without an auditor. Got expected pass/fail outcomes. Reviewers: chad Reviewed By: chad Maniphest Tasks: T5889 Differential Revision: https://secure.phabricator.com/D17221
This commit is contained in:
parent
a3b067291f
commit
545dad319e
3 changed files with 56 additions and 0 deletions
|
@ -617,6 +617,7 @@ phutil_register_library_map(array(
|
|||
'DiffusionCommitActionTransaction' => 'applications/diffusion/xaction/DiffusionCommitActionTransaction.php',
|
||||
'DiffusionCommitAffectedFilesHeraldField' => 'applications/diffusion/herald/DiffusionCommitAffectedFilesHeraldField.php',
|
||||
'DiffusionCommitAuditTransaction' => 'applications/diffusion/xaction/DiffusionCommitAuditTransaction.php',
|
||||
'DiffusionCommitAuditorsHeraldField' => 'applications/diffusion/herald/DiffusionCommitAuditorsHeraldField.php',
|
||||
'DiffusionCommitAuditorsTransaction' => 'applications/diffusion/xaction/DiffusionCommitAuditorsTransaction.php',
|
||||
'DiffusionCommitAuthorHeraldField' => 'applications/diffusion/herald/DiffusionCommitAuthorHeraldField.php',
|
||||
'DiffusionCommitAutocloseHeraldField' => 'applications/diffusion/herald/DiffusionCommitAutocloseHeraldField.php',
|
||||
|
@ -5321,6 +5322,7 @@ phutil_register_library_map(array(
|
|||
'DiffusionCommitActionTransaction' => 'DiffusionCommitTransactionType',
|
||||
'DiffusionCommitAffectedFilesHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitAuditTransaction' => 'DiffusionCommitActionTransaction',
|
||||
'DiffusionCommitAuditorsHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitAuditorsTransaction' => 'DiffusionCommitTransactionType',
|
||||
'DiffusionCommitAuthorHeraldField' => 'DiffusionCommitHeraldField',
|
||||
'DiffusionCommitAutocloseHeraldField' => 'DiffusionCommitHeraldField',
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionCommitAuditorsHeraldField
|
||||
extends DiffusionCommitHeraldField {
|
||||
|
||||
const FIELDCONST = 'diffusion.commit.auditors';
|
||||
|
||||
public function getHeraldFieldName() {
|
||||
return pht('Auditors');
|
||||
}
|
||||
|
||||
public function getHeraldFieldValue($object) {
|
||||
$viewer = PhabricatorUser::getOmnipotentUser();
|
||||
|
||||
$commit = id(new DiffusionCommitQuery())
|
||||
->setViewer($viewer)
|
||||
->withPHIDs(array($object->getPHID()))
|
||||
->needAuditRequests(true)
|
||||
->executeOne();
|
||||
|
||||
$audits = $commit->getAudits();
|
||||
|
||||
$phids = array();
|
||||
foreach ($audits as $audit) {
|
||||
if ($audit->isActiveAudit()) {
|
||||
$phids[] = $audit->getAuditorPHID();
|
||||
}
|
||||
}
|
||||
|
||||
return $phids;
|
||||
}
|
||||
|
||||
protected function getHeraldFieldStandardType() {
|
||||
return self::STANDARD_PHID_LIST;
|
||||
}
|
||||
|
||||
protected function getDatasource() {
|
||||
return new DiffusionAuditorDatasource();
|
||||
}
|
||||
|
||||
}
|
|
@ -49,6 +49,19 @@ final class PhabricatorRepositoryAuditRequest
|
|||
return $this->assertAttached($this->commit);
|
||||
}
|
||||
|
||||
public function isActiveAudit() {
|
||||
switch ($this->getAuditStatus()) {
|
||||
case PhabricatorAuditStatusConstants::NONE:
|
||||
case PhabricatorAuditStatusConstants::AUDIT_NOT_REQUIRED:
|
||||
case PhabricatorAuditStatusConstants::RESIGNED:
|
||||
case PhabricatorAuditStatusConstants::CLOSED:
|
||||
case PhabricatorAuditStatusConstants::CC:
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isInteresting() {
|
||||
switch ($this->getAuditStatus()) {
|
||||
case PhabricatorAuditStatusConstants::NONE:
|
||||
|
|
Loading…
Reference in a new issue