Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
radicle/cob/stream: skip commits that do not have a manifest
Merged fintohaps opened 4 months ago

For some COBs, parent commits can be specified for actions, for example, patches will bundle their base and head commits as parents.

When the COB stream performs the revwalk, these commits will be included, and will not have the manifest file – resulting in an error.

Instead, this error can be matched against, and the commit is skipped instead. The other errors should still be resurfaced, since a commit with a manifest should be expected to load the operation correctly, and the commit should exist in the repository when attempting to load it.

One might argue that a valid operation with a missing manifest could occur, but that would mean that radicle-cob has performed an invalid write. This is undetectable by the stream API, and is ambiguous with the case of non-Op commits.

1 file changed +8 -1 cf023f75 b8a6e1a5
modified crates/radicle/src/cob/stream/iter.rs
@@ -138,7 +138,14 @@ where
                // N.b. mark this commit as seen, so that it is not walked again
                self.walk.inner.hide(commit.id()).ok();
                // Skip any Op that do not match the manifest
-
                self.load(entry).transpose().or_else(|| self.next())
+
                match self.load(entry) {
+
                    Ok(entry) => entry.map(Ok).or_else(|| self.next()),
+
                    Err(err) => match err {
+
                        // This is a parent commit that is not an Op
+
                        error::Ops::Manifest { source: _ } => self.next(),
+
                        err => Some(Err(err)),
+
                    },
+
                }
            }
            // Something was wrong with the commit
            Err(err) => Some(Err(error::Ops::Commit { source: err })),