diff --git a/radicle/src/rad.rs b/radicle/src/rad.rs index 3653c5b9..4b2fff8b 100644 --- a/radicle/src/rad.rs +++ b/radicle/src/rad.rs @@ -164,7 +164,7 @@ pub fn fork( let me = signer.public_key(); let repository = storage.repository(proj)?; // TODO: We should get the id branch pointer from a stored canonical reference. - let (canonical_id, _) = repository.project_identity()?; + let (canonical_id, _) = repository.identity_doc()?; let (canonical_branch, canonical_head) = repository.head()?; let raw = repository.raw(); diff --git a/radicle/src/storage.rs b/radicle/src/storage.rs index 60c2449c..3a82644b 100644 --- a/radicle/src/storage.rs +++ b/radicle/src/storage.rs @@ -266,7 +266,9 @@ pub trait ReadRepository { /// The [`Path`] to the git repository. fn path(&self) -> &Path; - fn blob_at<'a>(&'a self, oid: Oid, path: &'a Path) -> Result, git_ext::Error>; + /// Get a blob in this repository at the given commit and path. + fn blob_at<'a>(&'a self, commit: Oid, path: &'a Path) + -> Result, git_ext::Error>; /// Get the head of this repository. /// @@ -297,18 +299,27 @@ pub trait ReadRepository { /// Returns `None` if the commit did not exist. fn commit(&self, oid: Oid) -> Result; + /// Perform a revision walk of a commit history starting from the given head. fn revwalk(&self, head: Oid) -> Result; + + /// Get the object id of a reference under the given remote. fn reference_oid( &self, remote: &RemoteId, reference: &Qualified, ) -> Result; + + /// Get all references of the given remote. fn references_of(&self, remote: &RemoteId) -> Result; + + /// Get the given remote. fn remote(&self, remote: &RemoteId) -> Result, refs::Error>; + + /// Get all remotes. fn remotes(&self) -> Result, refs::Error>; - /// Return the project associated with this repository. - fn project(&self) -> Result, Error>; - fn project_identity(&self) -> Result<(Oid, identity::Doc), ProjectError>; + + /// Get the repository's identity document. + fn identity_doc(&self) -> Result<(Oid, identity::Doc), ProjectError>; } pub trait WriteRepository: ReadRepository { diff --git a/radicle/src/storage/git.rs b/radicle/src/storage/git.rs index d996d47a..704e8f8a 100644 --- a/radicle/src/storage/git.rs +++ b/radicle/src/storage/git.rs @@ -531,11 +531,7 @@ impl ReadRepository for Repository { Ok(Remotes::from_iter(remotes)) } - fn project(&self) -> Result, Error> { - todo!() - } - - fn project_identity(&self) -> Result<(Oid, identity::Doc), ProjectError> { + fn identity_doc(&self) -> Result<(Oid, identity::Doc), ProjectError> { Repository::identity_doc(self) } @@ -552,7 +548,7 @@ impl ReadRepository for Repository { fn canonical_head(&self) -> Result<(Qualified, Oid), ProjectError> { // TODO: In the `fork` function for example, we call Repository::project_identity again, // This should only be necessary once. - let (_, doc) = self.project_identity()?; + let (_, doc) = self.identity_doc()?; let doc = doc.verified()?; let project = doc.project()?; let branch_ref = Qualified::from(lit::refs_heads(&project.default_branch())); diff --git a/radicle/src/test/storage.rs b/radicle/src/test/storage.rs index fd04c0ed..f0ccd9b7 100644 --- a/radicle/src/test/storage.rs +++ b/radicle/src/test/storage.rs @@ -120,11 +120,7 @@ impl ReadRepository for MockRepository { todo!() } - fn project(&self) -> Result, Error> { - todo!() - } - - fn project_identity( + fn identity_doc( &self, ) -> Result<(Oid, crate::identity::Doc), git::ProjectError> { todo!()