Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
radicle: Return individual results for repo in `repositories_by_id`
✗ CI failure Sebastian Martinez committed 6 months ago
commit 6d0c571ea9998dd98bf10cc191848029f5210d8a
parent c268e809e9dafb9f1d2879fb781d501dbcf61902
2 passed 4 failed (6 total) View logs
2 files changed +15 -8
modified 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<Item = Result<RepositoryInfo, RepositoryError>>` instead of
+
  `Result<Vec<RepositoryInfo>, 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.
modified 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<Item = &'a RepoId>,
-
    ) -> Result<Vec<RepositoryInfo>, RepositoryError> {
-
        rids.try_fold(Vec::new(), |mut infos, rid| {
+
        rids: I,
+
    ) -> impl Iterator<Item = Result<RepositoryInfo, RepositoryError>> + use<'_, 'a, I>
+
    where
+
        I: Iterator<Item = &'a RepoId>,
+
    {
+
        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)
+
            })
        })
    }