1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-19 19:21:10 +01:00

Implement more consistent publishing rules for repositories

Summary:
Ref T7298. We are currently inconsistent about when we publish feed, email, notifications, audits and Herald rules.

Specifically, there are two settings which impact these things:

  - The "importing" flag, which is set when we're importing old commits.
  - The "herald-disabled" flag, which was expanded in scope some time ago and now actually means "disable publishing".

Various parts of the pipeline were checking only one of these flags. Instead, all of them should check both.

(For example, we should never email users about importing repositories, nor trigger audits on them.)

Test Plan: See next revision.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T7298

Differential Revision: https://secure.phabricator.com/D11826
This commit is contained in:
epriestley 2015-02-19 10:38:05 -08:00
parent 29fd3f136b
commit 8599145b5e
4 changed files with 25 additions and 12 deletions

View file

@ -524,12 +524,14 @@ final class PhabricatorAuditEditor
array $xactions) {
// not every code path loads the repository so tread carefully
// TODO: They should, and then we should simplify this.
if ($object->getRepository($assert_attached = false)) {
$repository = $object->getRepository();
if ($repository->isImporting()) {
if (!$repository->shouldPublish()) {
return false;
}
}
return $this->isCommitMostlyImported($object);
}
@ -822,10 +824,7 @@ final class PhabricatorAuditEditor
switch ($xaction->getTransactionType()) {
case PhabricatorAuditTransaction::TYPE_COMMIT:
$repository = $object->getRepository();
if ($repository->isImporting()) {
return false;
}
if ($repository->getDetail('herald-disabled')) {
if (!$repository->shouldPublish()) {
return false;
}
return true;

View file

@ -676,6 +676,25 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
}
/**
* Should this repository publish feed, notifications, audits, and email?
*
* We do not publish information about repositories during initial import,
* or if the repository has been set not to publish.
*/
public function shouldPublish() {
if ($this->isImporting()) {
return false;
}
if ($this->getDetail('disable-herald')) {
return false;
}
return true;
}
/* -( Autoclose )---------------------------------------------------------- */

View file

@ -25,7 +25,7 @@ final class PhabricatorRepositoryCommitOwnersWorker
PhabricatorRepository $repository,
PhabricatorRepositoryCommit $commit) {
if ($repository->getDetail('herald-disabled')) {
if (!$repository->shouldPublish()) {
return;
}

View file

@ -22,16 +22,11 @@ final class PhabricatorRepositoryPushMailWorker
->executeOne();
$repository = $event->getRepository();
if ($repository->isImporting()) {
if (!$repository->shouldPublish()) {
// If the repository is still importing, don't send email.
return;
}
if ($repository->getDetail('herald-disabled')) {
// If publishing is disabled, don't send email.
return;
}
$logs = $event->getLogs();
list($ref_lines, $ref_list) = $this->renderRefs($logs);