From 02318f199c6f29a2eede1f282e1f9b99927d27ec Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Tue, 30 Dec 2025 08:58:01 +0000 Subject: [PATCH] radicle: Re-export `radicle_core::RepoId` --- crates/radicle/Cargo.toml | 13 +++++++++++-- crates/radicle/src/identity/doc.rs | 4 +--- crates/radicle/src/sql.rs | 24 ------------------------ crates/radicle/src/test/arbitrary.rs | 9 --------- 4 files changed, 12 insertions(+), 38 deletions(-) diff --git a/crates/radicle/Cargo.toml b/crates/radicle/Cargo.toml index 8b79ea53..d7dab007 100644 --- a/crates/radicle/Cargo.toml +++ b/crates/radicle/Cargo.toml @@ -13,7 +13,16 @@ rust-version.workspace = true default = [] test = ["tempfile", "qcheck", "radicle-crypto/test", "radicle-cob/test"] logger = ["colored", "chrono"] -schemars = ["radicle-oid/schemars", "radicle-localtime/schemars", "dep:schemars"] +qcheck = [ + "radicle-core/qcheck", + "dep:qcheck" +] +schemars = [ + "radicle-oid/schemars", + "radicle-core/schemars", + "radicle-localtime/schemars", + "dep:schemars" +] [dependencies] amplify = { workspace = true, features = ["std"] } @@ -33,7 +42,7 @@ multibase = { workspace = true } nonempty = { workspace = true, features = ["serialize"] } qcheck = { workspace = true, optional = true } radicle-cob = { workspace = true, features = ["git2"] } -radicle-core = { workspace = true, features = ["git2"] } +radicle-core = { workspace = true, features = ["git2", "serde", "sqlite"] } radicle-crypto = { workspace = true, features = ["git-ref-format-core", "ssh", "sqlite", "cyphernet"] } radicle-git-ref-format = { workspace = true, features = ["macro", "serde"] } radicle-localtime = { workspace = true, features = ["serde"] } diff --git a/crates/radicle/src/identity/doc.rs b/crates/radicle/src/identity/doc.rs index 3ecd0b5c..02e38bc0 100644 --- a/crates/radicle/src/identity/doc.rs +++ b/crates/radicle/src/identity/doc.rs @@ -1,7 +1,5 @@ pub mod update; -mod id; - use std::collections::{BTreeMap, BTreeSet}; use std::fmt; use std::num::{NonZeroU32, NonZeroUsize}; @@ -29,7 +27,7 @@ use crate::storage; use crate::storage::{ReadRepository, RepositoryError}; pub use crypto::PublicKey; -pub use id::*; +pub use radicle_core::repo::*; use super::crefs::{self, RawCanonicalRefs}; use super::CanonicalRefs; diff --git a/crates/radicle/src/sql.rs b/crates/radicle/src/sql.rs index f6dada6c..57818ff0 100644 --- a/crates/radicle/src/sql.rs +++ b/crates/radicle/src/sql.rs @@ -4,7 +4,6 @@ use std::str::FromStr; use sqlite as sql; use sqlite::Value; -use crate::identity::RepoId; use crate::node; use crate::node::{Address, UserAgent}; @@ -28,29 +27,6 @@ pub fn transaction>( } } -impl TryFrom<&Value> for RepoId { - type Error = sql::Error; - - fn try_from(value: &Value) -> Result { - match value { - Value::String(id) => RepoId::from_urn(id).map_err(|e| sql::Error { - code: None, - message: Some(e.to_string()), - }), - _ => Err(sql::Error { - code: None, - message: Some(format!("sql: invalid type `{:?}` for id", value.kind())), - }), - } - } -} - -impl sqlite::BindableWithIndex for &RepoId { - fn bind(self, stmt: &mut sql::Statement<'_>, i: I) -> sql::Result<()> { - self.urn().as_str().bind(stmt, i) - } -} - impl sql::BindableWithIndex for node::Features { fn bind(self, stmt: &mut sql::Statement<'_>, i: I) -> sql::Result<()> { (*self.deref() as i64).bind(stmt, i) diff --git a/crates/radicle/src/test/arbitrary.rs b/crates/radicle/src/test/arbitrary.rs index 1df2cd9d..a9af6bf3 100644 --- a/crates/radicle/src/test/arbitrary.rs +++ b/crates/radicle/src/test/arbitrary.rs @@ -270,15 +270,6 @@ impl Arbitrary for storage::Remote { } } -impl Arbitrary for RepoId { - fn arbitrary(g: &mut qcheck::Gen) -> Self { - let bytes = <[u8; 20]>::arbitrary(g); - let oid = crate::git::Oid::from_sha1(bytes); - - RepoId::from(oid) - } -} - impl Arbitrary for AddressType { fn arbitrary(g: &mut qcheck::Gen) -> Self { let t = *g.choose(&[1, 2, 3, 4]).unwrap() as u8;