Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
crypto: Depend on `git-ref-format-core` only
Merged lorenz opened 6 months ago

The git-ref-format-core crate is enough to implement everything required by radicle-crypto, and has a much smaller dependency footprint than radicle-git-ext. Notably, it does not depend on git2 and also does not depend on procedural macros.

6 files changed +18 -17 ac572e64 b25d80d2
modified Cargo.lock
@@ -2896,10 +2896,10 @@ dependencies = [
 "cyphernet",
 "ec25519",
 "fastrand",
+
 "git-ref-format-core",
 "multibase",
 "qcheck",
 "qcheck-macros",
-
 "radicle-git-ext",
 "radicle-ssh",
 "serde",
 "signature 2.2.0",
modified Cargo.toml
@@ -28,6 +28,7 @@ crossbeam-channel = "0.5.6"
cyphernet = "0.5.2"
dunce = "1.0.5"
fastrand = { version = "2.0.0", default-features = false }
+
git-ref-format-core = { version = "0.3.0", default-features = false }
git2 = { version = "0.19.0", default-features = false }
human-panic = "2"
itertools = "0.14"
modified crates/radicle-cob/Cargo.toml
@@ -35,5 +35,5 @@ thiserror = { workspace = true }
fastrand = { workspace = true }
qcheck = { workspace = true }
qcheck-macros = { workspace = true }
-
radicle-crypto = { workspace = true, features = ["test", "radicle-git-ext"] }
-
tempfile = { workspace = true }

\ No newline at end of file
+
radicle-crypto = { workspace = true, features = ["test", "git-ref-format-core"] }
+
tempfile = { workspace = true }
modified crates/radicle-crypto/Cargo.toml
@@ -23,7 +23,7 @@ ec25519 = "0.1.0"
fastrand = { workspace = true, optional = true }
multibase = { workspace = true }
qcheck = { workspace = true, optional = true }
-
radicle-git-ext = { workspace = true, optional = true }
+
git-ref-format-core = { workspace = true, optional = true }
radicle-ssh = { workspace = true, optional = true }
serde = { workspace = true, features = ["derive"] }
signature = { workspace = true }
modified crates/radicle-crypto/src/lib.rs
@@ -353,20 +353,20 @@ impl PublicKey {
        multibase::encode(multibase::Base::Base58Btc, buf)
    }

-
    #[cfg(feature = "radicle-git-ext")]
-
    pub fn to_namespace(&self) -> radicle_git_ext::ref_format::RefString {
-
        use radicle_git_ext::ref_format::{refname, Component};
-
        refname!("refs/namespaces").join(Component::from(self))
+
    #[cfg(feature = "git-ref-format-core")]
+
    pub fn to_namespace(&self) -> git_ref_format_core::RefString {
+
        use git_ref_format_core::name::{Component, NAMESPACES, REFS};
+
        REFS.to_owned().and(NAMESPACES).and(Component::from(self))
    }

-
    #[cfg(feature = "radicle-git-ext")]
-
    pub fn to_component(&self) -> radicle_git_ext::ref_format::Component {
-
        radicle_git_ext::ref_format::Component::from(self)
+
    #[cfg(feature = "git-ref-format-core")]
+
    pub fn to_component(&self) -> git_ref_format_core::Component {
+
        git_ref_format_core::Component::from(self)
    }

-
    #[cfg(feature = "radicle-git-ext")]
+
    #[cfg(feature = "git-ref-format-core")]
    pub fn from_namespaced(
-
        refstr: &radicle_git_ext::ref_format::Namespaced,
+
        refstr: &git_ref_format_core::Namespaced,
    ) -> Result<Self, PublicKeyError> {
        let name = refstr.namespace().into_inner();

@@ -406,10 +406,10 @@ impl Deref for PublicKey {
    }
}

-
#[cfg(feature = "radicle-git-ext")]
-
impl From<&PublicKey> for radicle_git_ext::ref_format::Component<'_> {
+
#[cfg(feature = "git-ref-format-core")]
+
impl From<&PublicKey> for git_ref_format_core::Component<'_> {
    fn from(id: &PublicKey) -> Self {
-
        use radicle_git_ext::ref_format::{Component, RefString};
+
        use git_ref_format_core::{Component, RefString};
        let refstr =
            RefString::try_from(id.to_string()).expect("encoded public keys are valid ref strings");
        Component::from_refstr(refstr).expect("encoded public keys are valid refname components")
modified crates/radicle/Cargo.toml
@@ -33,7 +33,7 @@ multibase = { workspace = true }
nonempty = { workspace = true, features = ["serialize"] }
qcheck = { workspace = true, optional = true }
radicle-cob = { workspace = true }
-
radicle-crypto = { workspace = true, features = ["radicle-git-ext", "ssh", "sqlite", "cyphernet"] }
+
radicle-crypto = { workspace = true, features = ["git-ref-format-core", "ssh", "sqlite", "cyphernet"] }
radicle-git-ext = { workspace = true, features = ["serde"] }
radicle-ssh = { workspace = true }
schemars = { workspace = true, optional = true }