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.
This commit is contained in:
Lorenz Leutgeb 2025-10-04 11:59:26 +02:00
parent ac572e64e5
commit b25d80d272
No known key found for this signature in database
6 changed files with 18 additions and 17 deletions

2
Cargo.lock generated
View File

@ -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",

View File

@ -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"

View File

@ -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 }
radicle-crypto = { workspace = true, features = ["test", "git-ref-format-core"] }
tempfile = { workspace = true }

View File

@ -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 }

View File

@ -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")

View File

@ -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 }