From 40083bfa0edc25548d0f1e72c3b300382ce8cb81 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 6 Apr 2011 16:27:57 -0700 Subject: [PATCH] Allow Herald to be disabled while importing a repository so we don't send a billion zillion emails. --- .../PhabricatorRepositoryEditController.php | 37 ++++++++++++++++++- .../repository/controller/edit/__init__.php | 1 + .../repository/PhabricatorRepository.php | 1 + ...habricatorRepositoryCommitHeraldWorker.php | 4 ++ 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/applications/repository/controller/edit/PhabricatorRepositoryEditController.php b/src/applications/repository/controller/edit/PhabricatorRepositoryEditController.php index 6dc2f7a0c0..3491dd6234 100644 --- a/src/applications/repository/controller/edit/PhabricatorRepositoryEditController.php +++ b/src/applications/repository/controller/edit/PhabricatorRepositoryEditController.php @@ -240,6 +240,14 @@ class PhabricatorRepositoryEditController 'default-owners-path', '/')); + $repository->setDetail( + 'herald-disabled', + $request->getInt('herald-disabled', 0)); + + if ($is_svn) { + $repository->setUUID($request->getStr('uuid')); + } + $repository->setDetail( 'detail-parser', $request->getStr( @@ -375,6 +383,21 @@ class PhabricatorRepositoryEditController '/')) ->setCaption('Default path in Owners tool.')); + $form + ->appendChild( + id(new AphrontFormSelectControl()) + ->setName('herald-disabled') + ->setLabel('Herald Enabled') + ->setValue($repository->getDetail('herald-disabled', 0)) + ->setOptions( + array( + 0 => 'Enabled - Send Email', + 1 => 'Disabled - Do Not Send Email', + )) + ->setCaption( + 'You can temporarily disable Herald notifications when reparsing '. + 'a repository or importing a new repository.')); + $parsers = id(new PhutilSymbolLoader()) ->setAncestorClass('PhabricatorRepositoryCommitMessageDetailParser') ->selectSymbolsWithoutLoading(); @@ -395,7 +418,19 @@ class PhabricatorRepositoryEditController ->setValue( $repository->getDetail( 'detail-parser', - 'PhabricatorRepositoryDefaultCommitMessageDetailParser'))) + 'PhabricatorRepositoryDefaultCommitMessageDetailParser'))); + + if ($is_svn) { + $form + ->appendChild( + id(new AphrontFormTextControl()) + ->setName('uuid') + ->setLabel('UUID') + ->setValue($repository->getUUID()) + ->setCaption('Repository UUID from svn info.')); + } + + $form ->appendChild( id(new AphrontFormSubmitControl()) ->setValue('Save')); diff --git a/src/applications/repository/controller/edit/__init__.php b/src/applications/repository/controller/edit/__init__.php index c1a90c0d27..dd59c75cee 100644 --- a/src/applications/repository/controller/edit/__init__.php +++ b/src/applications/repository/controller/edit/__init__.php @@ -16,6 +16,7 @@ phutil_require_module('phabricator', 'applications/repository/storage/repository phutil_require_module('phabricator', 'infrastructure/env'); phutil_require_module('phabricator', 'view/control/table'); phutil_require_module('phabricator', 'view/form/base'); +phutil_require_module('phabricator', 'view/form/control/select'); phutil_require_module('phabricator', 'view/form/control/submit'); phutil_require_module('phabricator', 'view/form/control/text'); phutil_require_module('phabricator', 'view/form/error'); diff --git a/src/applications/repository/storage/repository/PhabricatorRepository.php b/src/applications/repository/storage/repository/PhabricatorRepository.php index ec2e0f1059..0235e1a435 100644 --- a/src/applications/repository/storage/repository/PhabricatorRepository.php +++ b/src/applications/repository/storage/repository/PhabricatorRepository.php @@ -27,6 +27,7 @@ class PhabricatorRepository extends PhabricatorRepositoryDAO { protected $phid; protected $name; protected $callsign; + protected $uuid; protected $versionControlSystem; protected $details = array(); diff --git a/src/applications/repository/worker/herald/PhabricatorRepositoryCommitHeraldWorker.php b/src/applications/repository/worker/herald/PhabricatorRepositoryCommitHeraldWorker.php index fd53cf0be9..e7e722c48a 100644 --- a/src/applications/repository/worker/herald/PhabricatorRepositoryCommitHeraldWorker.php +++ b/src/applications/repository/worker/herald/PhabricatorRepositoryCommitHeraldWorker.php @@ -23,6 +23,10 @@ class PhabricatorRepositoryCommitHeraldWorker PhabricatorRepository $repository, PhabricatorRepositoryCommit $commit) { + if ($repository->getDetail('herald-disabled')) { + return; + } + $data = id(new PhabricatorRepositoryCommitData())->loadOneWhere( 'commitID = %d', $commit->getID());