aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/command
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-06 19:09:49 +0900
committernsfisis <nsfisis@gmail.com>2026-06-06 19:09:49 +0900
commitc688de488d72e67ab1650b50adef4ad11f5de756 (patch)
treeb522ef7c82abbe8f1318fa693cc98fdb6815db6c /crates/shirabe/src/command
parent23f8a0dc3e08949ec78e050b7642c605fa2aaaf5 (diff)
downloadphp-shirabe-c688de488d72e67ab1650b50adef4ad11f5de756.tar.gz
php-shirabe-c688de488d72e67ab1650b50adef4ad11f5de756.tar.zst
php-shirabe-c688de488d72e67ab1650b50adef4ad11f5de756.zip
refactor(installed-repository): make add_repository infallible with assert
The repository type check was an internal invariant, not a recoverable error condition. Replace the Result-returning validation with an assert!, matching Composer's design where add_repository throws only on a programming error, and drop the now-unneeded error handling at call sites. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/command')
-rw-r--r--crates/shirabe/src/command/base_dependency_command.rs14
-rw-r--r--crates/shirabe/src/command/show_command.rs2
2 files changed, 7 insertions, 9 deletions
diff --git a/crates/shirabe/src/command/base_dependency_command.rs b/crates/shirabe/src/command/base_dependency_command.rs
index 4a5b854..a9ed7cd 100644
--- a/crates/shirabe/src/command/base_dependency_command.rs
+++ b/crates/shirabe/src/command/base_dependency_command.rs
@@ -166,13 +166,11 @@ pub trait BaseDependencyCommand: BaseCommand {
&needle,
FindPackageConstraint::String(text_constraint.clone()),
)? {
- installed_repo.add_repository(
- crate::repository::RepositoryInterfaceHandle::new(
- InstalledArrayRepository::new_with_packages(vec![
- crate::package::PackageInterfaceHandle::dup(&r#match),
- ])?,
- ),
- )?;
+ installed_repo.add_repository(crate::repository::RepositoryInterfaceHandle::new(
+ InstalledArrayRepository::new_with_packages(vec![
+ crate::package::PackageInterfaceHandle::dup(&r#match),
+ ])?,
+ ));
} else if PlatformRepository::is_platform_package(&needle) {
let parser = VersionParser::new();
let platform_constraint = parser.parse_constraints(&text_constraint)?;
@@ -189,7 +187,7 @@ pub trait BaseDependencyCommand: BaseCommand {
.into(),
])?,
),
- )?;
+ );
}
} else {
self.get_io().write_error(&format!(
diff --git a/crates/shirabe/src/command/show_command.rs b/crates/shirabe/src/command/show_command.rs
index e14ab15..859ba97 100644
--- a/crates/shirabe/src/command/show_command.rs
+++ b/crates/shirabe/src/command/show_command.rs
@@ -270,7 +270,7 @@ impl ShowCommand {
.get_repository_manager()
.borrow()
.get_local_repository(),
- )?;
+ );
installed_repo = RepositoryInterfaceHandle::new(ir);
} else {
let default_repos =