mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-24 14:30:56 +01:00
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
This commit is contained in:
parent
74a79aa634
commit
b63eb09cac
2 changed files with 23 additions and 11 deletions
|
@ -134,7 +134,6 @@ final class DiffusionRepositoryCreateController
|
||||||
$type_name = PhabricatorRepositoryTransaction::TYPE_NAME;
|
$type_name = PhabricatorRepositoryTransaction::TYPE_NAME;
|
||||||
$type_vcs = PhabricatorRepositoryTransaction::TYPE_VCS;
|
$type_vcs = PhabricatorRepositoryTransaction::TYPE_VCS;
|
||||||
$type_activate = PhabricatorRepositoryTransaction::TYPE_ACTIVATE;
|
$type_activate = PhabricatorRepositoryTransaction::TYPE_ACTIVATE;
|
||||||
$type_local_path = PhabricatorRepositoryTransaction::TYPE_LOCAL_PATH;
|
|
||||||
$type_remote_uri = PhabricatorRepositoryTransaction::TYPE_REMOTE_URI;
|
$type_remote_uri = PhabricatorRepositoryTransaction::TYPE_REMOTE_URI;
|
||||||
$type_hosting = PhabricatorRepositoryTransaction::TYPE_HOSTING;
|
$type_hosting = PhabricatorRepositoryTransaction::TYPE_HOSTING;
|
||||||
$type_http = PhabricatorRepositoryTransaction::TYPE_PROTOCOL_HTTP;
|
$type_http = PhabricatorRepositoryTransaction::TYPE_PROTOCOL_HTTP;
|
||||||
|
@ -179,16 +178,6 @@ final class DiffusionRepositoryCreateController
|
||||||
->setTransactionType($type_service)
|
->setTransactionType($type_service)
|
||||||
->setNewValue($service->getPHID());
|
->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) {
|
if ($is_init) {
|
||||||
|
|
|
@ -522,4 +522,27 @@ final class PhabricatorRepositoryEditor
|
||||||
return true;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue