From 61b06553b461b982fb59808d1dad9d6a1548732a Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Thu, 19 Oct 2023 10:40:57 +0100 Subject: [PATCH] radicle: use git::raw::Error for reference_oid The minimal error for the `ReadRepository::reference_oid` method is `git::raw::Error`. Change the error type from `git::ext::Error` to `git::raw::Error`. Signed-off-by: Fintan Halpenny X-Clacks-Overhead: GNU Terry Pratchett --- radicle/src/cob/store.rs | 5 ++--- radicle/src/storage.rs | 2 +- radicle/src/storage/git.rs | 3 ++- radicle/src/storage/git/cob.rs | 2 +- radicle/src/storage/refs.rs | 4 ++-- radicle/src/test/storage.rs | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/radicle/src/cob/store.rs b/radicle/src/cob/store.rs index bc4f8ed4..6696da9c 100644 --- a/radicle/src/cob/store.rs +++ b/radicle/src/cob/store.rs @@ -94,7 +94,7 @@ pub enum Error { RefLookup { name: git::RefString, #[source] - err: git::Error, + err: git::raw::Error, }, } @@ -210,8 +210,7 @@ where self.repo.sign_refs(signer).map_err(Error::SignRefs)?; Ok(()) } - Err(git::Error::NotFound(_)) => Ok(()), - Err(git::Error::Git(err)) if err.code() == git::raw::ErrorCode::NotFound => Ok(()), + Err(err) if err.code() == git::raw::ErrorCode::NotFound => Ok(()), Err(err) => Err(Error::RefLookup { name: name.to_ref_string(), err, diff --git a/radicle/src/storage.rs b/radicle/src/storage.rs index af7affa3..bdc8c70e 100644 --- a/radicle/src/storage.rs +++ b/radicle/src/storage.rs @@ -441,7 +441,7 @@ pub trait ReadRepository: Sized + ValidateRepository { &self, remote: &RemoteId, reference: &Qualified, - ) -> Result; + ) -> Result; /// Get all references of the given remote. fn references_of(&self, remote: &RemoteId) -> Result; diff --git a/radicle/src/storage/git.rs b/radicle/src/storage/git.rs index f6f7699a..bb5ee63e 100644 --- a/radicle/src/storage/git.rs +++ b/radicle/src/storage/git.rs @@ -517,7 +517,7 @@ impl ReadRepository for Repository { &self, remote: &RemoteId, reference: &git::Qualified, - ) -> Result { + ) -> Result { let name = reference.with_namespace(remote.into()); let oid = self.backend.refname_to_id(&name)?; @@ -638,6 +638,7 @@ impl ReadRepository for Repository { fn identity_head_of(&self, remote: &RemoteId) -> Result { self.reference_oid(remote, &git::refs::storage::IDENTITY_BRANCH) + .map_err(git::ext::Error::from) } fn identity_root(&self) -> Result { diff --git a/radicle/src/storage/git/cob.rs b/radicle/src/storage/git/cob.rs index b7275a3d..7c1be334 100644 --- a/radicle/src/storage/git/cob.rs +++ b/radicle/src/storage/git/cob.rs @@ -306,7 +306,7 @@ impl<'a, R: storage::ReadRepository> ReadRepository for DraftStore<'a, R> { &self, remote: &RemoteId, reference: &git::Qualified, - ) -> Result { + ) -> Result { self.repo.reference_oid(remote, reference) } diff --git a/radicle/src/storage/refs.rs b/radicle/src/storage/refs.rs index e26b0ab3..d42b6f50 100644 --- a/radicle/src/storage/refs.rs +++ b/radicle/src/storage/refs.rs @@ -57,6 +57,7 @@ impl Error { match self { Self::GitExt(git::Error::NotFound(_)) => true, Self::GitExt(git::Error::Git(e)) if git::is_not_found_err(e) => true, + Self::Git(e) if git::is_not_found_err(e) => true, _ => false, } } @@ -385,8 +386,7 @@ impl SignedRefsAt { { let at = match repo.reference_oid(&remote, &SIGREFS_BRANCH) { Ok(at) => at, - Err(git::ext::Error::NotFound(_)) => return Ok(None), - Err(git::ext::Error::Git(e)) if git::is_not_found_err(&e) => return Ok(None), + Err(e) if git::is_not_found_err(&e) => return Ok(None), Err(e) => return Err(e.into()), }; Self::load_at(at, remote, repo).map(Some) diff --git a/radicle/src/test/storage.rs b/radicle/src/test/storage.rs index 1afada5c..7039b8fb 100644 --- a/radicle/src/test/storage.rs +++ b/radicle/src/test/storage.rs @@ -212,7 +212,7 @@ impl ReadRepository for MockRepository { &self, _remote: &RemoteId, _reference: &git::Qualified, - ) -> Result { + ) -> Result { Ok(Oid::from_str("ffffffffffffffffffffffffffffffffffffffff").unwrap()) }