diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-06 02:13:59 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-06 02:13:59 +0900 |
| commit | cd25c3e193f05a5e89bca2a1c706c85fdc9c9155 (patch) | |
| tree | 86971cac4e5011af0077416e6ca674c4251496ee /crates/shirabe/src/command/diagnose_command.rs | |
| parent | b299a0c9b66523b9630b4cf6d3dca1509c3692b5 (diff) | |
| download | php-shirabe-cd25c3e193f05a5e89bca2a1c706c85fdc9c9155.tar.gz php-shirabe-cd25c3e193f05a5e89bca2a1c706c85fdc9c9155.tar.zst php-shirabe-cd25c3e193f05a5e89bca2a1c706c85fdc9c9155.zip | |
refactor(repository): make read methods fallible and take &mut self
Change RepositoryInterface and WritableRepositoryInterface read methods
(find_package, find_packages, get_packages, load_packages, search,
get_providers, get_canonical_packages) to take &mut self and return
anyhow::Result, so lazy-loading repositories such as ComposerRepository
can perform fallible I/O and mutate internal state on access. Update all
implementors and call sites to propagate the Result and pass mutable
references.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/command/diagnose_command.rs')
| -rw-r--r-- | crates/shirabe/src/command/diagnose_command.rs | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/crates/shirabe/src/command/diagnose_command.rs b/crates/shirabe/src/command/diagnose_command.rs index bcedf30..d9ab5e2 100644 --- a/crates/shirabe/src/command/diagnose_command.rs +++ b/crates/shirabe/src/command/diagnose_command.rs @@ -162,12 +162,13 @@ impl DiagnoseCommand { .into_iter() .map(|(k, v)| (k, *v)) .collect(); - let platform_repo = PlatformRepository::new(vec![], platform_overrides_unboxed).unwrap(); + let mut platform_repo = + PlatformRepository::new(vec![], platform_overrides_unboxed).unwrap(); let php_pkg = <PlatformRepository as crate::repository::RepositoryInterface>::find_package( - &platform_repo, + &mut platform_repo, "php", crate::repository::FindPackageConstraint::String("*".to_string()), - ) + )? .unwrap(); let mut php_version = php_pkg.get_pretty_version().to_string(); if let Some(cp) = php_pkg.as_complete() { @@ -933,16 +934,14 @@ impl DiagnoseCommand { "url".to_string(), PhpMixed::String("https://packagist.org".to_string()), ); - // TODO(phase-b): ComposerRepository does not implement RepositoryInterface yet - let _composer_repo = ComposerRepository::new( - repo_config, - std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())), - config, - self.http_downloader.clone().unwrap(), - None, - )?; - let composer_repo_as_repo: crate::repository::RepositoryInterfaceHandle = - todo!("ComposerRepository as RepositoryInterface"); + let composer_repo_as_repo = + crate::repository::RepositoryInterfaceHandle::new(ComposerRepository::new( + repo_config, + std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())), + config, + self.http_downloader.clone().unwrap(), + None, + )?); repo_set.add_repository(composer_repo_as_repo)?; let mut io = BufferIO::new(String::new(), 0, None)?; |
