From b25d80d2729cbd988eca76bdfc5baa312426f1ac Mon Sep 17 00:00:00 2001 From: Lorenz Leutgeb Date: Sat, 4 Oct 2025 11:59:26 +0200 Subject: [PATCH] crypto: Depend on `git-ref-format-core` only 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. --- Cargo.lock | 2 +- Cargo.toml | 1 + crates/radicle-cob/Cargo.toml | 4 ++-- crates/radicle-crypto/Cargo.toml | 2 +- crates/radicle-crypto/src/lib.rs | 24 ++++++++++++------------ crates/radicle/Cargo.toml | 2 +- 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9eea1fd6..131b20ba 100644 --- a/Cargo.lock +++ b/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", diff --git a/Cargo.toml b/Cargo.toml index 48052087..56580781 100644 --- a/Cargo.toml +++ b/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" diff --git a/crates/radicle-cob/Cargo.toml b/crates/radicle-cob/Cargo.toml index d9dbc0c3..15bffd7c 100644 --- a/crates/radicle-cob/Cargo.toml +++ b/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 } diff --git a/crates/radicle-crypto/Cargo.toml b/crates/radicle-crypto/Cargo.toml index 3a238c34..e3533d23 100644 --- a/crates/radicle-crypto/Cargo.toml +++ b/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 } diff --git a/crates/radicle-crypto/src/lib.rs b/crates/radicle-crypto/src/lib.rs index 0a7f3df5..dc4085e4 100644 --- a/crates/radicle-crypto/src/lib.rs +++ b/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 { 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") diff --git a/crates/radicle/Cargo.toml b/crates/radicle/Cargo.toml index 57bee257..835e0be3 100644 --- a/crates/radicle/Cargo.toml +++ b/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 }