Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cob: add method for loading entry manifest
Fintan Halpenny committed 8 months ago
commit bfe8c5234f79287d23ec1ace72d59dc1dcb54e35
parent 86119473b7c17e8f1090d52f79a2433089f1825f
5 files changed +25 -0
modified crates/radicle-cob/src/backend/git/change.rs
@@ -159,6 +159,12 @@ impl change::Storage for git2::Repository {
            .collect::<Vec<_>>())
    }

+
    fn manifest_of(&self, id: &Oid) -> Result<crate::Manifest, Self::LoadError> {
+
        let commit = self.find_commit(**id)?;
+
        let tree = commit.tree()?;
+
        load_manifest(self, &tree)
+
    }
+

    fn load(&self, id: Self::ObjectId) -> Result<Entry, Self::LoadError> {
        let commit = Commit::read(self, id.into())?;
        let timestamp = git2::Time::from(commit.committer().time).seconds() as u64;
modified crates/radicle-cob/src/change/store.rs
@@ -38,6 +38,9 @@ pub trait Storage {

    /// Returns the parents of the object with the specified ID.
    fn parents_of(&self, id: &Oid) -> Result<Vec<Oid>, Self::LoadError>;
+

+
    /// Load only the manifest of the change entry.
+
    fn manifest_of(&self, id: &Oid) -> Result<Manifest, Self::LoadError>;
}

/// Change template, used to create a new change.
modified crates/radicle-cob/src/test/storage.rs
@@ -101,6 +101,10 @@ impl change::Storage for Storage {
            .map(git_ext::Oid::from)
            .collect::<Vec<_>>())
    }
+

+
    fn manifest_of(&self, id: &git_ext::Oid) -> Result<crate::Manifest, Self::LoadError> {
+
        self.as_raw().manifest_of(id)
+
    }
}

impl object::Storage for Storage {
modified crates/radicle/src/storage/git/cob.rs
@@ -82,6 +82,10 @@ impl change::Storage for Repository {
    fn parents_of(&self, id: &Oid) -> Result<Vec<Oid>, Self::LoadError> {
        self.backend.parents_of(id)
    }
+

+
    fn manifest_of(&self, id: &Oid) -> Result<cob::Manifest, Self::LoadError> {
+
        self.backend.manifest_of(id)
+
    }
}

impl cob::object::Storage for Repository {
@@ -223,6 +227,10 @@ impl<R: storage::WriteRepository> change::Storage for DraftStore<'_, R> {
    fn parents_of(&self, id: &Oid) -> Result<Vec<Oid>, Self::LoadError> {
        self.repo.raw().parents_of(id)
    }
+

+
    fn manifest_of(&self, id: &Oid) -> Result<cob::Manifest, Self::LoadError> {
+
        self.repo.raw().manifest_of(id)
+
    }
}

impl<R> SignRepository for DraftStore<'_, R>
modified crates/radicle/src/test/storage.rs
@@ -440,4 +440,8 @@ impl radicle_cob::change::Storage for MockRepository {
    fn parents_of(&self, _id: &Oid) -> Result<Vec<Oid>, Self::LoadError> {
        todo!()
    }
+

+
    fn manifest_of(&self, _id: &Oid) -> Result<radicle_cob::Manifest, Self::LoadError> {
+
        todo!()
+
    }
}