3 final class PhabricatorRepositoryEditor
4 extends PhabricatorApplicationTransactionEditor
{
6 public function getEditorApplicationClass() {
7 return 'PhabricatorDiffusionApplication';
10 public function getEditorObjectsDescription() {
11 return pht('Repositories');
14 public function getTransactionTypes() {
15 $types = parent
::getTransactionTypes();
17 $types[] = PhabricatorTransactions
::TYPE_EDGE
;
18 $types[] = PhabricatorTransactions
::TYPE_VIEW_POLICY
;
19 $types[] = PhabricatorTransactions
::TYPE_EDIT_POLICY
;
24 protected function didCatchDuplicateKeyException(
25 PhabricatorLiskDAO
$object,
31 $errors[] = new PhabricatorApplicationTransactionValidationError(
35 'The chosen callsign or repository short name is already in '.
36 'use by another repository.'),
39 throw new PhabricatorApplicationTransactionValidationException($errors);
42 protected function supportsSearch() {
46 protected function applyFinalEffects(
47 PhabricatorLiskDAO
$object,
50 // If the repository does not have a local path yet, assign it one based
51 // on its ID. We can't do this earlier because we won't have an ID yet.
52 $local_path = $object->getLocalPath();
53 if ($local_path === null ||
!strlen($local_path)) {
54 $local_key = 'repository.default-local-path';
56 $local_root = PhabricatorEnv
::getEnvConfig($local_key);
57 $local_root = rtrim($local_root, '/');
59 $id = $object->getID();
60 $local_path = "{$local_root}/{$id}/";
62 $object->setLocalPath($local_path);
66 if ($this->getIsNewObject()) {
67 // The default state of repositories is to be hosted, if they are
68 // enabled without configuring any "Observe" URIs.
69 $object->setHosted(true);
72 // Create this repository's builtin URIs.
73 $builtin_uris = $object->newBuiltinURIs();
74 foreach ($builtin_uris as $uri) {
78 id(new DiffusionRepositoryClusterEngine())
79 ->setViewer($this->getActor())
80 ->setRepository($object)
81 ->synchronizeWorkingCopyAfterCreation();
84 $object->writeStatusMessage(
85 PhabricatorRepositoryStatusMessage
::TYPE_NEEDS_UPDATE
,