aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--crates/shirabe/src/command/base_dependency_command.rs14
-rw-r--r--crates/shirabe/src/command/show_command.rs2
-rw-r--r--crates/shirabe/src/repository/installed_repository.rs30
3 files changed, 17 insertions, 29 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 =
diff --git a/crates/shirabe/src/repository/installed_repository.rs b/crates/shirabe/src/repository/installed_repository.rs
index b8321d6..2bd6fc6 100644
--- a/crates/shirabe/src/repository/installed_repository.rs
+++ b/crates/shirabe/src/repository/installed_repository.rs
@@ -43,9 +43,7 @@ impl InstalledRepository {
inner: CompositeRepository::new(vec![]),
};
for repo in repositories {
- // TODO(phase-b): add_repository validates the inner repo type and may return Err;
- // ignoring the error during Phase B since callers do not handle it.
- let _ = this.add_repository(repo);
+ this.add_repository(repo);
}
this
}
@@ -366,24 +364,16 @@ impl InstalledRepository {
Ok(results)
}
- pub fn add_repository(&mut self, repository: RepositoryInterfaceHandle) -> anyhow::Result<()> {
- if repository.is::<LockArrayRepository>()
- || repository.is::<RootPackageRepository>()
- || repository.is::<PlatformRepository>()
- {
- self.inner.add_repository(repository);
- return Ok(());
- }
+ pub fn add_repository(&mut self, repository: RepositoryInterfaceHandle) {
+ // TODO: type guard?
+ assert!(
+ repository.is::<LockArrayRepository>()
+ || repository.is::<RootPackageRepository>()
+ || repository.is::<PlatformRepository>(),
+ "An InstalledRepository can contain a repository of type: LockArrayRepository, RootPackageRepository or PlatformRepository"
+ );
- let type_name = std::any::type_name_of_val(&*repository.borrow()).to_string();
- let repo_name = repository.get_repo_name();
- Err(anyhow::anyhow!(LogicException {
- message: format!(
- "An InstalledRepository can not contain a repository of type {} ({})",
- type_name, repo_name,
- ),
- code: 0,
- }))
+ self.inner.add_repository(repository);
}
}