@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator

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

+23 -11
-11
src/applications/diffusion/controller/DiffusionRepositoryCreateController.php
··· 134 134 $type_name = PhabricatorRepositoryTransaction::TYPE_NAME; 135 135 $type_vcs = PhabricatorRepositoryTransaction::TYPE_VCS; 136 136 $type_activate = PhabricatorRepositoryTransaction::TYPE_ACTIVATE; 137 - $type_local_path = PhabricatorRepositoryTransaction::TYPE_LOCAL_PATH; 138 137 $type_remote_uri = PhabricatorRepositoryTransaction::TYPE_REMOTE_URI; 139 138 $type_hosting = PhabricatorRepositoryTransaction::TYPE_HOSTING; 140 139 $type_http = PhabricatorRepositoryTransaction::TYPE_PROTOCOL_HTTP; ··· 179 178 ->setTransactionType($type_service) 180 179 ->setNewValue($service->getPHID()); 181 180 } 182 - 183 - $default_local_path = PhabricatorEnv::getEnvConfig( 184 - 'repository.default-local-path'); 185 - 186 - $default_local_path = rtrim($default_local_path, '/'); 187 - $default_local_path = $default_local_path.'/'.$callsign.'/'; 188 - 189 - $xactions[] = id(clone $template) 190 - ->setTransactionType($type_local_path) 191 - ->setNewValue($default_local_path); 192 181 } 193 182 194 183 if ($is_init) {
+23
src/applications/repository/editor/PhabricatorRepositoryEditor.php
··· 522 522 return true; 523 523 } 524 524 525 + protected function applyFinalEffects( 526 + PhabricatorLiskDAO $object, 527 + array $xactions) { 528 + 529 + // If the repository does not have a local path yet, assign it one based 530 + // on its ID. We can't do this earlier because we won't have an ID yet. 531 + $local_path = $object->getDetail('local-path'); 532 + if (!strlen($local_path)) { 533 + $local_key = 'repository.default-local-path'; 534 + 535 + $local_root = PhabricatorEnv::getEnvConfig($local_key); 536 + $local_root = rtrim($local_root, '/'); 537 + 538 + $id = $object->getID(); 539 + $local_path = "{$local_root}/{$id}/"; 540 + 541 + $object->setDetail('local-path', $local_path); 542 + $object->save(); 543 + } 544 + 545 + return $xactions; 546 + } 547 + 525 548 }