1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 23:02:42 +01:00

Add global "push" policy to Repositories

Summary: No editing or view yet, just adds the schema and a policy default. Part of D7391.

Test Plan: `bin/storage upgrade`

Reviewers: hach-que, btrahan

Reviewed By: hach-que

CC: aran

Maniphest Tasks: T2230

Differential Revision: https://secure.phabricator.com/D7415
This commit is contained in:
epriestley 2013-10-25 19:12:52 -07:00
parent ba63c5e426
commit 86fe020a97
6 changed files with 56 additions and 3 deletions

View file

@ -0,0 +1,5 @@
ALTER TABLE {$NAMESPACE}_repository.repository
ADD COLUMN pushPolicy VARCHAR(64) NOT NULL COLLATE utf8_bin;
UPDATE {$NAMESPACE}_repository.repository
SET pushPolicy = 'users' WHERE pushPolicy = '';

View file

@ -451,7 +451,9 @@ phutil_register_library_map(array(
'DiffusionBrowseTableView' => 'applications/diffusion/view/DiffusionBrowseTableView.php', 'DiffusionBrowseTableView' => 'applications/diffusion/view/DiffusionBrowseTableView.php',
'DiffusionCapabilityCreateRepositories' => 'applications/diffusion/capability/DiffusionCapabilityCreateRepositories.php', 'DiffusionCapabilityCreateRepositories' => 'applications/diffusion/capability/DiffusionCapabilityCreateRepositories.php',
'DiffusionCapabilityDefaultEdit' => 'applications/diffusion/capability/DiffusionCapabilityDefaultEdit.php', 'DiffusionCapabilityDefaultEdit' => 'applications/diffusion/capability/DiffusionCapabilityDefaultEdit.php',
'DiffusionCapabilityDefaultPush' => 'applications/diffusion/capability/DiffusionCapabilityDefaultPush.php',
'DiffusionCapabilityDefaultView' => 'applications/diffusion/capability/DiffusionCapabilityDefaultView.php', 'DiffusionCapabilityDefaultView' => 'applications/diffusion/capability/DiffusionCapabilityDefaultView.php',
'DiffusionCapabilityPush' => 'applications/diffusion/capability/DiffusionCapabilityPush.php',
'DiffusionChangeController' => 'applications/diffusion/controller/DiffusionChangeController.php', 'DiffusionChangeController' => 'applications/diffusion/controller/DiffusionChangeController.php',
'DiffusionCommentListView' => 'applications/diffusion/view/DiffusionCommentListView.php', 'DiffusionCommentListView' => 'applications/diffusion/view/DiffusionCommentListView.php',
'DiffusionCommentView' => 'applications/diffusion/view/DiffusionCommentView.php', 'DiffusionCommentView' => 'applications/diffusion/view/DiffusionCommentView.php',
@ -1631,7 +1633,6 @@ phutil_register_library_map(array(
'PhabricatorRepositoryCommitSearchIndexer' => 'applications/repository/search/PhabricatorRepositoryCommitSearchIndexer.php', 'PhabricatorRepositoryCommitSearchIndexer' => 'applications/repository/search/PhabricatorRepositoryCommitSearchIndexer.php',
'PhabricatorRepositoryConfigOptions' => 'applications/repository/PhabricatorRepositoryConfigOptions.php', 'PhabricatorRepositoryConfigOptions' => 'applications/repository/PhabricatorRepositoryConfigOptions.php',
'PhabricatorRepositoryController' => 'applications/repository/controller/PhabricatorRepositoryController.php', 'PhabricatorRepositoryController' => 'applications/repository/controller/PhabricatorRepositoryController.php',
'PhabricatorRepositoryCreateController' => 'applications/repository/controller/PhabricatorRepositoryCreateController.php',
'PhabricatorRepositoryDAO' => 'applications/repository/storage/PhabricatorRepositoryDAO.php', 'PhabricatorRepositoryDAO' => 'applications/repository/storage/PhabricatorRepositoryDAO.php',
'PhabricatorRepositoryDiscoveryEngine' => 'applications/repository/engine/PhabricatorRepositoryDiscoveryEngine.php', 'PhabricatorRepositoryDiscoveryEngine' => 'applications/repository/engine/PhabricatorRepositoryDiscoveryEngine.php',
'PhabricatorRepositoryEditController' => 'applications/repository/controller/PhabricatorRepositoryEditController.php', 'PhabricatorRepositoryEditController' => 'applications/repository/controller/PhabricatorRepositoryEditController.php',
@ -2639,7 +2640,9 @@ phutil_register_library_map(array(
'DiffusionBrowseTableView' => 'DiffusionView', 'DiffusionBrowseTableView' => 'DiffusionView',
'DiffusionCapabilityCreateRepositories' => 'PhabricatorPolicyCapability', 'DiffusionCapabilityCreateRepositories' => 'PhabricatorPolicyCapability',
'DiffusionCapabilityDefaultEdit' => 'PhabricatorPolicyCapability', 'DiffusionCapabilityDefaultEdit' => 'PhabricatorPolicyCapability',
'DiffusionCapabilityDefaultPush' => 'PhabricatorPolicyCapability',
'DiffusionCapabilityDefaultView' => 'PhabricatorPolicyCapability', 'DiffusionCapabilityDefaultView' => 'PhabricatorPolicyCapability',
'DiffusionCapabilityPush' => 'PhabricatorPolicyCapability',
'DiffusionChangeController' => 'DiffusionController', 'DiffusionChangeController' => 'DiffusionController',
'DiffusionCommentListView' => 'AphrontView', 'DiffusionCommentListView' => 'AphrontView',
'DiffusionCommentView' => 'AphrontView', 'DiffusionCommentView' => 'AphrontView',
@ -3961,7 +3964,6 @@ phutil_register_library_map(array(
'PhabricatorRepositoryCommitSearchIndexer' => 'PhabricatorSearchDocumentIndexer', 'PhabricatorRepositoryCommitSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
'PhabricatorRepositoryConfigOptions' => 'PhabricatorApplicationConfigOptions', 'PhabricatorRepositoryConfigOptions' => 'PhabricatorApplicationConfigOptions',
'PhabricatorRepositoryController' => 'PhabricatorController', 'PhabricatorRepositoryController' => 'PhabricatorController',
'PhabricatorRepositoryCreateController' => 'PhabricatorRepositoryController',
'PhabricatorRepositoryDAO' => 'PhabricatorLiskDAO', 'PhabricatorRepositoryDAO' => 'PhabricatorLiskDAO',
'PhabricatorRepositoryDiscoveryEngine' => 'PhabricatorRepositoryEngine', 'PhabricatorRepositoryDiscoveryEngine' => 'PhabricatorRepositoryEngine',
'PhabricatorRepositoryEditController' => 'PhabricatorRepositoryController', 'PhabricatorRepositoryEditController' => 'PhabricatorRepositoryController',

View file

@ -0,0 +1,16 @@
<?php
final class DiffusionCapabilityDefaultPush
extends PhabricatorPolicyCapability {
const CAPABILITY = 'diffusion.default.push';
public function getCapabilityKey() {
return self::CAPABILITY;
}
public function getCapabilityName() {
return pht('Default Push Policy');
}
}

View file

@ -0,0 +1,20 @@
<?php
final class DiffusionCapabilityPush
extends PhabricatorPolicyCapability {
const CAPABILITY = 'diffusion.push';
public function getCapabilityKey() {
return self::CAPABILITY;
}
public function getCapabilityName() {
return pht('Can Push');
}
public function describeCapabilityRejection() {
return pht('You do not have permission to push to this repository.');
}
}

View file

@ -31,6 +31,7 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
protected $uuid; protected $uuid;
protected $viewPolicy; protected $viewPolicy;
protected $editPolicy; protected $editPolicy;
protected $pushPolicy;
protected $versionControlSystem; protected $versionControlSystem;
protected $details = array(); protected $details = array();
@ -48,10 +49,12 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
$view_policy = $app->getPolicy(DiffusionCapabilityDefaultView::CAPABILITY); $view_policy = $app->getPolicy(DiffusionCapabilityDefaultView::CAPABILITY);
$edit_policy = $app->getPolicy(DiffusionCapabilityDefaultEdit::CAPABILITY); $edit_policy = $app->getPolicy(DiffusionCapabilityDefaultEdit::CAPABILITY);
$push_policy = $app->getPolicy(DiffusionCapabilityDefaultPush::CAPABILITY);
return id(new PhabricatorRepository()) return id(new PhabricatorRepository())
->setViewPolicy($view_policy) ->setViewPolicy($view_policy)
->setEditPolicy($edit_policy); ->setEditPolicy($edit_policy)
->setPushPolicy($push_policy);
} }
public function getConfiguration() { public function getConfiguration() {
@ -713,6 +716,7 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
return array( return array(
PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT, PhabricatorPolicyCapability::CAN_EDIT,
DiffusionCapabilityPush::CAPABILITY,
); );
} }
@ -722,6 +726,8 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
return $this->getViewPolicy(); return $this->getViewPolicy();
case PhabricatorPolicyCapability::CAN_EDIT: case PhabricatorPolicyCapability::CAN_EDIT:
return $this->getEditPolicy(); return $this->getEditPolicy();
case DiffusionCapabilityPush::CAPABILITY:
return $this->getPushPolicy();
} }
} }

View file

@ -1704,6 +1704,10 @@ final class PhabricatorBuiltinPatchList extends PhabricatorSQLPatchList {
'type' => 'sql', 'type' => 'sql',
'name' => $this->getPatchPath('20131020.harbormaster.sql'), 'name' => $this->getPatchPath('20131020.harbormaster.sql'),
), ),
'20131025.repopush.sql' => array(
'type' => 'sql',
'name' => $this->getPatchPath('20131025.repopush.sql'),
),
); );
} }
} }