aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/command/init_command.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-07 10:32:26 +0900
committernsfisis <nsfisis@gmail.com>2026-06-07 10:34:37 +0900
commite1053c6881da1bba409a16783e01a89248507a66 (patch)
tree17da41e7fe48b675434338e41e5ecefcff5894db /crates/shirabe/src/command/init_command.rs
parent971824aa15334fd12d08ae0f441f6bf6079344c3 (diff)
downloadphp-shirabe-e1053c6881da1bba409a16783e01a89248507a66.tar.gz
php-shirabe-e1053c6881da1bba409a16783e01a89248507a66.tar.zst
php-shirabe-e1053c6881da1bba409a16783e01a89248507a66.zip
refactor(phase-c): share PlatformRepository and RepositorySet via handles
PHP shares a single PlatformRepository by reference across the RepositorySet, createRequest, VersionSelector, and (in show) the installed repository. The port worked with owned values / &mut, so it could not share: create_repository_set silently dropped the platform repo from the pool (PlatformRepository is not Clone), show rebuilt a fresh PlatformRepository per use, and the package discovery / show version selectors were stubbed because VersionSelector wanted an owned RepositorySet. Thread the existing PlatformRepositoryHandle (Rc<RefCell<PlatformRepository>>) through installer.rs and show, restoring the RootPackageRepository + platform repo registration and implementing same_repository via RepositoryInterfaceHandle ptr_eq. Hold package-discovery repos as a shared RepositoryInterfaceHandle, and share RepositorySet as Rc<RefCell<RepositorySet>> in the set caches and VersionSelector (which only reads it), unblocking both stubbed selector sites and dropping show's placeholder set. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/command/init_command.rs')
-rw-r--r--crates/shirabe/src/command/init_command.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/crates/shirabe/src/command/init_command.rs b/crates/shirabe/src/command/init_command.rs
index eabe6e2..5a3c71b 100644
--- a/crates/shirabe/src/command/init_command.rs
+++ b/crates/shirabe/src/command/init_command.rs
@@ -44,13 +44,14 @@ pub struct InitCommand {
}
impl PackageDiscoveryTrait for InitCommand {
- fn get_repos_mut(&mut self) -> &mut Option<CompositeRepository> {
+ fn get_repos_mut(&mut self) -> &mut Option<crate::repository::RepositoryInterfaceHandle> {
todo!()
}
fn get_repository_sets_mut(
&mut self,
- ) -> &mut IndexMap<String, crate::repository::RepositorySet> {
+ ) -> &mut IndexMap<String, std::rc::Rc<std::cell::RefCell<crate::repository::RepositorySet>>>
+ {
todo!()
}
@@ -512,7 +513,9 @@ impl InitCommand {
)?);
}
- *self.get_repos_mut() = Some(CompositeRepository::new(repos));
+ *self.get_repos_mut() = Some(crate::repository::RepositoryInterfaceHandle::new(
+ CompositeRepository::new(repos),
+ ));
// unset($repos, $config, $repositories);
}
@@ -746,7 +749,7 @@ impl InitCommand {
io.write_error3("\nDefine your dependencies.\n", true, io_interface::NORMAL);
// prepare to resolve dependencies
- let repos = self.get_repos();
+ let _repos = self.get_repos();
let preferred_stability =
if let Some(s) = minimum_stability_default.clone().filter(|s| !s.is_empty()) {
s