mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +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:
parent
ba63c5e426
commit
86fe020a97
6 changed files with 56 additions and 3 deletions
5
resources/sql/patches/20131025.repopush.sql
Normal file
5
resources/sql/patches/20131025.repopush.sql
Normal 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 = '';
|
|
@ -451,7 +451,9 @@ phutil_register_library_map(array(
|
|||
'DiffusionBrowseTableView' => 'applications/diffusion/view/DiffusionBrowseTableView.php',
|
||||
'DiffusionCapabilityCreateRepositories' => 'applications/diffusion/capability/DiffusionCapabilityCreateRepositories.php',
|
||||
'DiffusionCapabilityDefaultEdit' => 'applications/diffusion/capability/DiffusionCapabilityDefaultEdit.php',
|
||||
'DiffusionCapabilityDefaultPush' => 'applications/diffusion/capability/DiffusionCapabilityDefaultPush.php',
|
||||
'DiffusionCapabilityDefaultView' => 'applications/diffusion/capability/DiffusionCapabilityDefaultView.php',
|
||||
'DiffusionCapabilityPush' => 'applications/diffusion/capability/DiffusionCapabilityPush.php',
|
||||
'DiffusionChangeController' => 'applications/diffusion/controller/DiffusionChangeController.php',
|
||||
'DiffusionCommentListView' => 'applications/diffusion/view/DiffusionCommentListView.php',
|
||||
'DiffusionCommentView' => 'applications/diffusion/view/DiffusionCommentView.php',
|
||||
|
@ -1631,7 +1633,6 @@ phutil_register_library_map(array(
|
|||
'PhabricatorRepositoryCommitSearchIndexer' => 'applications/repository/search/PhabricatorRepositoryCommitSearchIndexer.php',
|
||||
'PhabricatorRepositoryConfigOptions' => 'applications/repository/PhabricatorRepositoryConfigOptions.php',
|
||||
'PhabricatorRepositoryController' => 'applications/repository/controller/PhabricatorRepositoryController.php',
|
||||
'PhabricatorRepositoryCreateController' => 'applications/repository/controller/PhabricatorRepositoryCreateController.php',
|
||||
'PhabricatorRepositoryDAO' => 'applications/repository/storage/PhabricatorRepositoryDAO.php',
|
||||
'PhabricatorRepositoryDiscoveryEngine' => 'applications/repository/engine/PhabricatorRepositoryDiscoveryEngine.php',
|
||||
'PhabricatorRepositoryEditController' => 'applications/repository/controller/PhabricatorRepositoryEditController.php',
|
||||
|
@ -2639,7 +2640,9 @@ phutil_register_library_map(array(
|
|||
'DiffusionBrowseTableView' => 'DiffusionView',
|
||||
'DiffusionCapabilityCreateRepositories' => 'PhabricatorPolicyCapability',
|
||||
'DiffusionCapabilityDefaultEdit' => 'PhabricatorPolicyCapability',
|
||||
'DiffusionCapabilityDefaultPush' => 'PhabricatorPolicyCapability',
|
||||
'DiffusionCapabilityDefaultView' => 'PhabricatorPolicyCapability',
|
||||
'DiffusionCapabilityPush' => 'PhabricatorPolicyCapability',
|
||||
'DiffusionChangeController' => 'DiffusionController',
|
||||
'DiffusionCommentListView' => 'AphrontView',
|
||||
'DiffusionCommentView' => 'AphrontView',
|
||||
|
@ -3961,7 +3964,6 @@ phutil_register_library_map(array(
|
|||
'PhabricatorRepositoryCommitSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
|
||||
'PhabricatorRepositoryConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
||||
'PhabricatorRepositoryController' => 'PhabricatorController',
|
||||
'PhabricatorRepositoryCreateController' => 'PhabricatorRepositoryController',
|
||||
'PhabricatorRepositoryDAO' => 'PhabricatorLiskDAO',
|
||||
'PhabricatorRepositoryDiscoveryEngine' => 'PhabricatorRepositoryEngine',
|
||||
'PhabricatorRepositoryEditController' => 'PhabricatorRepositoryController',
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
||||
}
|
|
@ -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.');
|
||||
}
|
||||
|
||||
}
|
|
@ -31,6 +31,7 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
|
|||
protected $uuid;
|
||||
protected $viewPolicy;
|
||||
protected $editPolicy;
|
||||
protected $pushPolicy;
|
||||
|
||||
protected $versionControlSystem;
|
||||
protected $details = array();
|
||||
|
@ -48,10 +49,12 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
|
|||
|
||||
$view_policy = $app->getPolicy(DiffusionCapabilityDefaultView::CAPABILITY);
|
||||
$edit_policy = $app->getPolicy(DiffusionCapabilityDefaultEdit::CAPABILITY);
|
||||
$push_policy = $app->getPolicy(DiffusionCapabilityDefaultPush::CAPABILITY);
|
||||
|
||||
return id(new PhabricatorRepository())
|
||||
->setViewPolicy($view_policy)
|
||||
->setEditPolicy($edit_policy);
|
||||
->setEditPolicy($edit_policy)
|
||||
->setPushPolicy($push_policy);
|
||||
}
|
||||
|
||||
public function getConfiguration() {
|
||||
|
@ -713,6 +716,7 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
|
|||
return array(
|
||||
PhabricatorPolicyCapability::CAN_VIEW,
|
||||
PhabricatorPolicyCapability::CAN_EDIT,
|
||||
DiffusionCapabilityPush::CAPABILITY,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -722,6 +726,8 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
|
|||
return $this->getViewPolicy();
|
||||
case PhabricatorPolicyCapability::CAN_EDIT:
|
||||
return $this->getEditPolicy();
|
||||
case DiffusionCapabilityPush::CAPABILITY:
|
||||
return $this->getPushPolicy();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1704,6 +1704,10 @@ final class PhabricatorBuiltinPatchList extends PhabricatorSQLPatchList {
|
|||
'type' => 'sql',
|
||||
'name' => $this->getPatchPath('20131020.harbormaster.sql'),
|
||||
),
|
||||
'20131025.repopush.sql' => array(
|
||||
'type' => 'sql',
|
||||
'name' => $this->getPatchPath('20131025.repopush.sql'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue