radicle: Re-export `radicle_core::RepoId`

This commit is contained in:
Fintan Halpenny 2025-12-30 08:58:01 +00:00 committed by Lorenz Leutgeb
parent 73827f5362
commit 02318f199c
4 changed files with 12 additions and 38 deletions

View File

@ -13,7 +13,16 @@ rust-version.workspace = true
default = [] default = []
test = ["tempfile", "qcheck", "radicle-crypto/test", "radicle-cob/test"] test = ["tempfile", "qcheck", "radicle-crypto/test", "radicle-cob/test"]
logger = ["colored", "chrono"] 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] [dependencies]
amplify = { workspace = true, features = ["std"] } amplify = { workspace = true, features = ["std"] }
@ -33,7 +42,7 @@ multibase = { workspace = true }
nonempty = { workspace = true, features = ["serialize"] } nonempty = { workspace = true, features = ["serialize"] }
qcheck = { workspace = true, optional = true } qcheck = { workspace = true, optional = true }
radicle-cob = { workspace = true, features = ["git2"] } 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-crypto = { workspace = true, features = ["git-ref-format-core", "ssh", "sqlite", "cyphernet"] }
radicle-git-ref-format = { workspace = true, features = ["macro", "serde"] } radicle-git-ref-format = { workspace = true, features = ["macro", "serde"] }
radicle-localtime = { workspace = true, features = ["serde"] } radicle-localtime = { workspace = true, features = ["serde"] }

View File

@ -1,7 +1,5 @@
pub mod update; pub mod update;
mod id;
use std::collections::{BTreeMap, BTreeSet}; use std::collections::{BTreeMap, BTreeSet};
use std::fmt; use std::fmt;
use std::num::{NonZeroU32, NonZeroUsize}; use std::num::{NonZeroU32, NonZeroUsize};
@ -29,7 +27,7 @@ use crate::storage;
use crate::storage::{ReadRepository, RepositoryError}; use crate::storage::{ReadRepository, RepositoryError};
pub use crypto::PublicKey; pub use crypto::PublicKey;
pub use id::*; pub use radicle_core::repo::*;
use super::crefs::{self, RawCanonicalRefs}; use super::crefs::{self, RawCanonicalRefs};
use super::CanonicalRefs; use super::CanonicalRefs;

View File

@ -4,7 +4,6 @@ use std::str::FromStr;
use sqlite as sql; use sqlite as sql;
use sqlite::Value; use sqlite::Value;
use crate::identity::RepoId;
use crate::node; use crate::node;
use crate::node::{Address, UserAgent}; use crate::node::{Address, UserAgent};
@ -28,29 +27,6 @@ pub fn transaction<T, E: From<sql::Error>>(
} }
} }
impl TryFrom<&Value> for RepoId {
type Error = sql::Error;
fn try_from(value: &Value) -> Result<Self, Self::Error> {
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<I: sql::ParameterIndex>(self, stmt: &mut sql::Statement<'_>, i: I) -> sql::Result<()> {
self.urn().as_str().bind(stmt, i)
}
}
impl sql::BindableWithIndex for node::Features { impl sql::BindableWithIndex for node::Features {
fn bind<I: sql::ParameterIndex>(self, stmt: &mut sql::Statement<'_>, i: I) -> sql::Result<()> { fn bind<I: sql::ParameterIndex>(self, stmt: &mut sql::Statement<'_>, i: I) -> sql::Result<()> {
(*self.deref() as i64).bind(stmt, i) (*self.deref() as i64).bind(stmt, i)

View File

@ -270,15 +270,6 @@ impl Arbitrary for storage::Remote<crypto::Unverified> {
} }
} }
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 { impl Arbitrary for AddressType {
fn arbitrary(g: &mut qcheck::Gen) -> Self { fn arbitrary(g: &mut qcheck::Gen) -> Self {
let t = *g.choose(&[1, 2, 3, 4]).unwrap() as u8; let t = *g.choose(&[1, 2, 3, 4]).unwrap() as u8;