diff --git a/crates/radicle/CHANGELOG.md b/crates/radicle/CHANGELOG.md index 7e1b130f..cf7590e6 100644 --- a/crates/radicle/CHANGELOG.md +++ b/crates/radicle/CHANGELOG.md @@ -18,6 +18,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- `radicle::storage::git::Storage::repositories_by_id` returns + `impl Iterator>` instead of + `Result, RepositoryError>`. Allowing callers to handle + failures on a per-repository basis rather than having the entire operation + fail if a single repository lookup fails. - Re-exports from `git2` at `radicle::git::raw` were limited, using the heartwood workspace as a filter. Dependents that require members that are not exported anymore will have to depend on `git2` directly. diff --git a/crates/radicle/src/storage/git.rs b/crates/radicle/src/storage/git.rs index f2592805..d36c33ca 100644 --- a/crates/radicle/src/storage/git.rs +++ b/crates/radicle/src/storage/git.rs @@ -236,11 +236,14 @@ impl Storage { self.path.as_path() } - pub fn repositories_by_id<'a>( + pub fn repositories_by_id<'a, I>( &self, - mut rids: impl Iterator, - ) -> Result, RepositoryError> { - rids.try_fold(Vec::new(), |mut infos, rid| { + rids: I, + ) -> impl Iterator> + use<'_, 'a, I> + where + I: Iterator, + { + rids.map(|rid| { let repo = self.repository(*rid)?; let (_, head) = repo.head()?; let refs = refs::SignedRefsAt::load(self.info.key, &repo)?; @@ -248,15 +251,14 @@ impl Storage { .as_ref() .map(|r| SyncedAt::new(r.at, &repo)) .transpose()?; - let info = RepositoryInfo { + + Ok(RepositoryInfo { rid: *rid, head, doc: repo.identity_doc()?.into(), refs, synced_at, - }; - infos.push(info); - Ok(infos) + }) }) }