diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-10 02:41:34 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-10 02:46:18 +0900 |
| commit | 2d474e91e49c7343d28198eff2b5bbbed9afbcee (patch) | |
| tree | 8c1ab321dfa5ddc1ca9d2871eb06a6fde6b2970b /crates/shirabe/src/repository | |
| parent | e583112899cbea7494ffdd73d7de380dd5f808c4 (diff) | |
| download | php-shirabe-2d474e91e49c7343d28198eff2b5bbbed9afbcee.tar.gz php-shirabe-2d474e91e49c7343d28198eff2b5bbbed9afbcee.tar.zst php-shirabe-2d474e91e49c7343d28198eff2b5bbbed9afbcee.zip | |
feat(phase-c): resolve cross-module phase-b TODOs
Diffstat (limited to 'crates/shirabe/src/repository')
8 files changed, 28 insertions, 19 deletions
diff --git a/crates/shirabe/src/repository/array_repository.rs b/crates/shirabe/src/repository/array_repository.rs index df25235..1bee17b 100644 --- a/crates/shirabe/src/repository/array_repository.rs +++ b/crates/shirabe/src/repository/array_repository.rs @@ -144,6 +144,11 @@ impl ArrayRepository { pub(crate) fn initialize(&self) { *self.packages.borrow_mut() = Some(vec![]); } + + /// Resets the packages cache so the next access re-runs `initialize`. + pub(crate) fn reset_packages(&self) { + *self.packages.borrow_mut() = None; + } } impl RepositoryInterface for ArrayRepository { diff --git a/crates/shirabe/src/repository/filesystem_repository.rs b/crates/shirabe/src/repository/filesystem_repository.rs index 4a18dc9..411fa13 100644 --- a/crates/shirabe/src/repository/filesystem_repository.rs +++ b/crates/shirabe/src/repository/filesystem_repository.rs @@ -186,8 +186,7 @@ impl FilesystemRepository { } pub fn reload(&mut self) -> Result<()> { - // TODO(phase-b): clear inner packages cache (PHP: $this->packages = null) - self.inner.reload(); + self.inner.reset_packages(); self.initialize() } diff --git a/crates/shirabe/src/repository/repository_factory.rs b/crates/shirabe/src/repository/repository_factory.rs index 89334a1..993699f 100644 --- a/crates/shirabe/src/repository/repository_factory.rs +++ b/crates/shirabe/src/repository/repository_factory.rs @@ -321,10 +321,10 @@ impl RepositoryFactory { Ok(repo_map) } - pub fn generate_repository_name( + pub fn generate_repository_name<T>( index: &PhpMixed, repo: &IndexMap<String, PhpMixed>, - existing_repos: &IndexMap<String, RepositoryInterfaceHandle>, + existing_repos: &IndexMap<String, T>, ) -> String { let mut name = match index { PhpMixed::Int(_) => { diff --git a/crates/shirabe/src/repository/repository_set.rs b/crates/shirabe/src/repository/repository_set.rs index f632fbc..bf7b525 100644 --- a/crates/shirabe/src/repository/repository_set.rs +++ b/crates/shirabe/src/repository/repository_set.rs @@ -618,7 +618,6 @@ impl RepositorySet { } if !allowed_packages.is_empty() { - // TODO(phase-b): Request::restrict_packages signature request.restrict_packages(allowed_packages); } diff --git a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs index 7eb253a..59e6b88 100644 --- a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs +++ b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs @@ -494,7 +494,9 @@ impl GitBitbucketDriver { /// @inheritDoc pub fn get_source(&self, identifier: &str) -> IndexMap<String, String> { if let Some(fallback) = self.fallback_driver.as_ref() { - // TODO(phase-b): trait returns Result; flatten for the inherent signature here + // TODO(phase-c): PHP getSource is infallible (: array), but the Rust trait made it + // Result, so the fallback's Result is flattened here. The faithful fix is making the + // VcsDriverInterface get_source/get_dist infallible across all implementations. return fallback.get_source(identifier).unwrap_or_default(); } @@ -511,7 +513,7 @@ impl GitBitbucketDriver { /// @inheritDoc pub fn get_dist(&self, identifier: &str) -> Option<IndexMap<String, String>> { if let Some(fallback) = self.fallback_driver.as_ref() { - // TODO(phase-b): trait returns Result; flatten for the inherent signature here + // TODO(phase-c): see get_source above — the trait's over-fallibility is flattened here. return fallback.get_dist(identifier).ok().flatten(); } @@ -886,14 +888,14 @@ impl GitBitbucketDriver { } if !extension_loaded("openssl") { - io.write_error( + io.write_error3( &format!( "Skipping Bitbucket git driver for {} because the OpenSSL PHP extension is missing.", url ), + true, + io_interface::VERBOSE, ); - // PHP: writeError(..., true, io_interface::VERBOSE) - // TODO(phase-b): io_interface::VERBOSE verbosity argument return Ok(false); } diff --git a/crates/shirabe/src/repository/vcs/svn_driver.rs b/crates/shirabe/src/repository/vcs/svn_driver.rs index f4e2bba..911e982 100644 --- a/crates/shirabe/src/repository/vcs/svn_driver.rs +++ b/crates/shirabe/src/repository/vcs/svn_driver.rs @@ -33,8 +33,6 @@ pub struct SvnDriver { /// @var ?string pub(crate) root_identifier: Option<String>, - /// @var string|false - // TODO(phase-b): PHP uses 'false' as a sentinel; model as Option<String> pub(crate) trunk_path: Option<String>, /// @var string pub(crate) branches_path: String, @@ -79,8 +77,10 @@ impl SvnDriver { SvnUtil::clean_env(); - if let Some(PhpMixed::String(v)) = self.inner.repo_config.get("trunk-path").cloned() { - self.trunk_path = Some(v); + match self.inner.repo_config.get("trunk-path") { + Some(PhpMixed::Bool(false)) => self.trunk_path = None, + Some(PhpMixed::String(v)) => self.trunk_path = Some(v.clone()), + _ => {} } if let Some(PhpMixed::String(v)) = self.inner.repo_config.get("branches-path").cloned() { self.branches_path = v; @@ -100,10 +100,11 @@ impl SvnDriver { self.package_path = format!("/{}", trim(&v, Some("/"))); } - if let Some(trunk_path) = &self.trunk_path { - if let Some(pos) = strrpos(&self.inner.url, &format!("/{}", trunk_path)) { - self.base_url = substr(&self.inner.url, 0, Some(pos as i64)); - } + if let Some(pos) = strrpos( + &self.inner.url, + &format!("/{}", self.trunk_path.as_deref().unwrap_or("")), + ) { + self.base_url = substr(&self.inner.url, 0, Some(pos as i64)); } self.inner.cache = Some(Cache::new( diff --git a/crates/shirabe/src/repository/vcs/vcs_driver.rs b/crates/shirabe/src/repository/vcs/vcs_driver.rs index 1c05933..740d00e 100644 --- a/crates/shirabe/src/repository/vcs/vcs_driver.rs +++ b/crates/shirabe/src/repository/vcs/vcs_driver.rs @@ -234,7 +234,6 @@ pub trait VcsDriver: VcsDriverInterface { if self.should_cache(identifier) { if let Some(ref composer_map) = composer { - // TODO(phase-b): use a dedicated encode-with-options helper; reuse encode for now. let composer_mixed = PhpMixed::Array( composer_map .iter() diff --git a/crates/shirabe/src/repository/writable_array_repository.rs b/crates/shirabe/src/repository/writable_array_repository.rs index bf9d094..0615ef6 100644 --- a/crates/shirabe/src/repository/writable_array_repository.rs +++ b/crates/shirabe/src/repository/writable_array_repository.rs @@ -48,6 +48,10 @@ impl WritableArrayRepository { self.dev_mode = None; } + pub fn reset_packages(&self) { + self.inner.reset_packages(); + } + pub fn add_package(&mut self, package: crate::package::PackageInterfaceHandle) -> Result<()> { self.inner.add_package(package) } |
