From b63eb09cacf1214fe98e03558336231bd087ead2 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 18 Feb 2016 05:27:01 -0800 Subject: [PATCH] Don't require a callsign to set a repository's local path Summary: Ref T4245. When creating new repositories, set a default local path based on the repository ID instead of callsign. Test Plan: - Created a new repository. - Saw it get a reasonable, ID-based local path. - Edited a repository to make sure the `applyFinalEffects()` wasn't doing anything whacky. Reviewers: chad Reviewed By: chad Maniphest Tasks: T4245 Differential Revision: https://secure.phabricator.com/D15303 --- .../DiffusionRepositoryCreateController.php | 11 --------- .../editor/PhabricatorRepositoryEditor.php | 23 +++++++++++++++++++ 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/applications/diffusion/controller/DiffusionRepositoryCreateController.php b/src/applications/diffusion/controller/DiffusionRepositoryCreateController.php index c6e2796fc1..4b876f3cf9 100644 --- a/src/applications/diffusion/controller/DiffusionRepositoryCreateController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryCreateController.php @@ -134,7 +134,6 @@ final class DiffusionRepositoryCreateController $type_name = PhabricatorRepositoryTransaction::TYPE_NAME; $type_vcs = PhabricatorRepositoryTransaction::TYPE_VCS; $type_activate = PhabricatorRepositoryTransaction::TYPE_ACTIVATE; - $type_local_path = PhabricatorRepositoryTransaction::TYPE_LOCAL_PATH; $type_remote_uri = PhabricatorRepositoryTransaction::TYPE_REMOTE_URI; $type_hosting = PhabricatorRepositoryTransaction::TYPE_HOSTING; $type_http = PhabricatorRepositoryTransaction::TYPE_PROTOCOL_HTTP; @@ -179,16 +178,6 @@ final class DiffusionRepositoryCreateController ->setTransactionType($type_service) ->setNewValue($service->getPHID()); } - - $default_local_path = PhabricatorEnv::getEnvConfig( - 'repository.default-local-path'); - - $default_local_path = rtrim($default_local_path, '/'); - $default_local_path = $default_local_path.'/'.$callsign.'/'; - - $xactions[] = id(clone $template) - ->setTransactionType($type_local_path) - ->setNewValue($default_local_path); } if ($is_init) { diff --git a/src/applications/repository/editor/PhabricatorRepositoryEditor.php b/src/applications/repository/editor/PhabricatorRepositoryEditor.php index 54f737c232..f6674835fc 100644 --- a/src/applications/repository/editor/PhabricatorRepositoryEditor.php +++ b/src/applications/repository/editor/PhabricatorRepositoryEditor.php @@ -522,4 +522,27 @@ final class PhabricatorRepositoryEditor return true; } + protected function applyFinalEffects( + PhabricatorLiskDAO $object, + array $xactions) { + + // If the repository does not have a local path yet, assign it one based + // on its ID. We can't do this earlier because we won't have an ID yet. + $local_path = $object->getDetail('local-path'); + if (!strlen($local_path)) { + $local_key = 'repository.default-local-path'; + + $local_root = PhabricatorEnv::getEnvConfig($local_key); + $local_root = rtrim($local_root, '/'); + + $id = $object->getID(); + $local_path = "{$local_root}/{$id}/"; + + $object->setDetail('local-path', $local_path); + $object->save(); + } + + return $xactions; + } + }