Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
Cleanup some of the git error variants
Alexis Sellier committed 3 years ago
commit c183f80a229c25d59656d4c910f1c771ea0fba01
parent d309f593b1ac8640e05c8c122f51d832ed259d61
3 files changed +11 -10
modified radicle/src/identity.rs
@@ -28,11 +28,13 @@ pub struct Trusted;
#[derive(Error, Debug)]
pub enum IdentityError {
    #[error("git: {0}")]
-
    GitRaw(#[from] git2::Error),
+
    Git(#[from] git2::Error),
    #[error("git: {0}")]
-
    Git(#[from] git::Error),
+
    GitExt(#[from] git::Error),
    #[error("root hash `{0}` does not match project")]
    MismatchedRoot(Oid),
+
    #[error("the document root is missing")]
+
    MissingRoot,
    #[error("commit signature for {0} is invalid: {1}")]
    InvalidSignature(PublicKey, crypto::Error),
    #[error("commit message for {0} is invalid")]
@@ -43,8 +45,6 @@ pub enum IdentityError {
    QuorumNotReached(usize, usize),
    #[error("identity document error: {0}")]
    Doc(#[from] doc::DocError),
-
    #[error("the document root is missing")]
-
    MissingRoot,
}

#[derive(Clone, Debug, PartialEq, Eq)]
modified radicle/src/identity/doc.rs
@@ -41,17 +41,18 @@ pub enum DocError {
    #[error("invalid threshold `{0}`: {1}")]
    Threshold(usize, &'static str),
    #[error("git: {0}")]
-
    Git(#[from] git::Error),
+
    GitExt(#[from] git::Error),
    #[error("git: {0}")]
-
    RawGit(#[from] git2::Error),
+
    Git(#[from] git2::Error),
}

impl DocError {
    /// Whether this error is caused by the document not being found.
    pub fn is_not_found(&self) -> bool {
        match self {
-
            Self::Git(git::Error::NotFound(_)) => true,
-
            Self::Git(git::Error::Git(e)) if git::is_not_found_err(e) => true,
+
            Self::GitExt(git::Error::NotFound(_)) => true,
+
            Self::GitExt(git::Error::Git(e)) if git::is_not_found_err(e) => true,
+
            Self::Git(err) if git::is_not_found_err(err) => true,
            _ => false,
        }
    }
modified radicle/src/rad.rs
@@ -88,9 +88,9 @@ pub enum ForkError {
    #[error("ref string: {0}")]
    RefString(#[from] git::fmt::Error),
    #[error("git: {0}")]
-
    GitRaw(#[from] git2::Error),
+
    Git(#[from] git2::Error),
    #[error("git: {0}")]
-
    Git(#[from] git::Error),
+
    GitExt(#[from] git::Error),
    #[error("storage: {0}")]
    Storage(#[from] storage::Error),
    #[error("payload: {0}")]