diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-06 20:38:08 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-06 20:38:08 +0900 |
| commit | a7bd624b3e9d4e9493435be1e6016303830e7087 (patch) | |
| tree | a52f74539dea9a302e99d8dad6e6c952dd27f13a /crates | |
| parent | 9411867aa23f8f4f3a6b21b4e8ca9f498a16283a (diff) | |
| download | php-shirabe-a7bd624b3e9d4e9493435be1e6016303830e7087.tar.gz php-shirabe-a7bd624b3e9d4e9493435be1e6016303830e7087.tar.zst php-shirabe-a7bd624b3e9d4e9493435be1e6016303830e7087.zip | |
fix(repository-manager): fail explicitly on an unknown repository class
createRepository instantiates `new $class(...)` from the name registered
for the type. The port dispatches over the classes it implements, and the
remaining arm was a todo!(). setRepositoryClass is public API, so a plugin
registering a class of its own reached it and panicked.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates')
| -rw-r--r-- | crates/shirabe/src/repository/repository_manager.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/crates/shirabe/src/repository/repository_manager.rs b/crates/shirabe/src/repository/repository_manager.rs index 5f74fc90..7fd2f80a 100644 --- a/crates/shirabe/src/repository/repository_manager.rs +++ b/crates/shirabe/src/repository/repository_manager.rs @@ -10,7 +10,7 @@ use crate::repository::RepositoryInterfaceHandle; use crate::util::HttpDownloader; use crate::util::ProcessExecutor; use indexmap::IndexMap; -use shirabe_php_shim::{InvalidArgumentException, PhpMixed, json_encode}; +use shirabe_php_shim::{InvalidArgumentException, PhpMixed, RuntimeException, json_encode}; use shirabe_semver::constraint::AnyConstraint; #[derive(Debug)] @@ -191,10 +191,12 @@ impl RepositoryManager { Some(self.process.clone()), )?, )), - other => todo!( - "dynamic class instantiation is not implemented for repository class {}", - other - ), + // TODO(plugin): `setRepositoryClass` lets a plugin register a repository class of + // its own, which needs a Rust-side counterpart before it can be built here. + other => Err(anyhow::anyhow!(RuntimeException { + message: format!("Repository class has no Rust implementation: {other}"), + code: 0, + })), } } |
