1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-21 04:50:55 +01:00

Improve audit behavior for "uninteresting" auditors

Summary:
Ref T10939. Fixes T10174. We can currently trigger "uninteresting" auditors in two ways:

  - Packages with auditing disabled ("NONE" audits).
  - Packages with auditing enabled, but they don't need an audit (e.g., author is a pacakge owner; "NOT REQUIRED" audits).

These audits aren't interesting (we only write them so we can list "commits in this package" from other UIs) but right now they take up the audit slot. In particular:

  - They show in the UI, but are generally useless/confusing nowadays. The actual table of contents does a better job of just showing "which packages do these paths belong to" now, and shows all packages for each path.
  - They block Herald from adding real auditors.

Change this:

  - Don't show uninteresting auditors.
  - Let Herald upgrade uninteresting auditors into real auditors.

Test Plan:
  - Ran `bin/repository reparse --owners <commit> --force`, and `--herald` to trigger Owners and Herald rules.
  - With a package with auditing disabled, triggered a "None" audit and saw it no longer appear in the UI with the patch applied.
  - With a package with auditing disabled, added a Herald rule to trigger an audit. With the patch, saw it go through and upgrade the audit to "Audit Required".

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10174, T10939

Differential Revision: https://secure.phabricator.com/D15940
This commit is contained in:
epriestley 2016-05-17 11:56:38 -07:00
parent 9c24798e64
commit de1a30efc7
4 changed files with 38 additions and 7 deletions

View file

@ -159,8 +159,18 @@ final class PhabricatorAuditEditor
$requests = mpull($requests, null, 'getAuditorPHID'); $requests = mpull($requests, null, 'getAuditorPHID');
foreach ($add as $phid) { foreach ($add as $phid) {
if (isset($requests[$phid])) { if (isset($requests[$phid])) {
$request = $requests[$phid];
// Only update an existing request if the current status is not
// an interesting status.
if ($request->isInteresting()) {
continue; continue;
} }
} else {
$request = id(new PhabricatorRepositoryAuditRequest())
->setCommitPHID($object->getPHID())
->setAuditorPHID($phid);
}
if ($this->getIsHeraldEditor()) { if ($this->getIsHeraldEditor()) {
$audit_requested = $xaction->getMetadataValue('auditStatus'); $audit_requested = $xaction->getMetadataValue('auditStatus');
@ -170,12 +180,13 @@ final class PhabricatorAuditEditor
$audit_requested = PhabricatorAuditStatusConstants::AUDIT_REQUESTED; $audit_requested = PhabricatorAuditStatusConstants::AUDIT_REQUESTED;
$audit_reason = $this->getAuditReasons($phid); $audit_reason = $this->getAuditReasons($phid);
} }
$requests[] = id(new PhabricatorRepositoryAuditRequest())
->setCommitPHID($object->getPHID()) $request
->setAuditorPHID($phid)
->setAuditStatus($audit_requested) ->setAuditStatus($audit_requested)
->setAuditReasons($audit_reason) ->setAuditReasons($audit_reason)
->save(); ->save();
$requests[$phid] = $request;
} }
$object->attachAudits($requests); $object->attachAudits($requests);

View file

@ -455,7 +455,12 @@ final class DiffusionCommitController extends DiffusionController {
if ($audit_requests) { if ($audit_requests) {
$user_requests = array(); $user_requests = array();
$other_requests = array(); $other_requests = array();
foreach ($audit_requests as $audit_request) { foreach ($audit_requests as $audit_request) {
if (!$audit_request->isInteresting()) {
continue;
}
if ($audit_request->isUser()) { if ($audit_request->isUser()) {
$user_requests[] = $audit_request; $user_requests[] = $audit_request;
} else { } else {
@ -471,7 +476,7 @@ final class DiffusionCommitController extends DiffusionController {
if ($other_requests) { if ($other_requests) {
$view->addProperty( $view->addProperty(
pht('Project/Package Auditors'), pht('Group Auditors'),
$this->renderAuditStatusView($other_requests)); $this->renderAuditStatusView($other_requests));
} }
} }

View file

@ -18,8 +18,13 @@ abstract class DiffusionAuditorsHeraldAction
$object = $adapter->getObject(); $object = $adapter->getObject();
$auditors = $object->getAudits(); $auditors = $object->getAudits();
$auditors = mpull($auditors, null, 'getAuditorPHID');
$current = array_keys($auditors); $current = array();
foreach ($auditors as $auditor) {
if ($auditor->isInteresting()) {
$current[] = $auditor->getAuditorPHID();
}
}
$allowed_types = array( $allowed_types = array(
PhabricatorPeopleUserPHIDType::TYPECONST, PhabricatorPeopleUserPHIDType::TYPECONST,

View file

@ -49,6 +49,16 @@ final class PhabricatorRepositoryAuditRequest
return $this->assertAttached($this->commit); return $this->assertAttached($this->commit);
} }
public function isInteresting() {
switch ($this->getAuditStatus()) {
case PhabricatorAuditStatusConstants::NONE:
case PhabricatorAuditStatusConstants::AUDIT_NOT_REQUIRED:
return false;
}
return true;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */ /* -( PhabricatorPolicyInterface )----------------------------------------- */