diff --git a/Cargo.lock b/Cargo.lock index cad83807..be2d6970 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1719,6 +1719,7 @@ checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", "hashbrown", + "serde", ] [[package]] @@ -2479,6 +2480,7 @@ dependencies = [ "fast-glob", "fastrand", "git2", + "indexmap", "jsonschema", "libc", "localtime", diff --git a/crates/radicle-cli/examples/rad-config.md b/crates/radicle-cli/examples/rad-config.md index a55cadb7..6e208b20 100644 --- a/crates/radicle-cli/examples/rad-config.md +++ b/crates/radicle-cli/examples/rad-config.md @@ -136,7 +136,7 @@ Values for changes are being validated. ``` (fail) $ rad config set web.pinned.repositories 5 -✗ Error: writing configuration to "[..]/.radicle/config.json" failed: validation failure due to invalid type: integer `5`, expected a sequence +✗ Error: writing configuration to "[..]/.radicle/config.json" failed: validation failure due to invalid type: integer `5`, expected a set ``` The type of the operation is validated. diff --git a/crates/radicle/Cargo.toml b/crates/radicle/Cargo.toml index dd7fe4ef..052c536a 100644 --- a/crates/radicle/Cargo.toml +++ b/crates/radicle/Cargo.toml @@ -25,6 +25,7 @@ cyphernet = { workspace = true, features = ["tor", "dns", "p2p-ed25519"] } fast-glob = { version = "0.3.2" } fastrand = { workspace = true } git2 = { workspace = true, features = ["vendored-libgit2"] } +indexmap = { version = "2", features = ["serde"] } libc = { workspace = true } localtime = { workspace = true, features = ["serde"] } log = { workspace = true, features = ["std"] } diff --git a/crates/radicle/src/web.rs b/crates/radicle/src/web.rs index 41387b17..4094b5d5 100644 --- a/crates/radicle/src/web.rs +++ b/crates/radicle/src/web.rs @@ -1,6 +1,7 @@ -use crate::prelude::RepoId; +use indexmap::IndexSet; use serde::{Deserialize, Serialize}; -use std::collections::HashSet; + +use crate::prelude::RepoId; /// Web configuration. #[derive(Clone, Debug, Default, Serialize, Deserialize)] @@ -34,5 +35,9 @@ pub struct Config { #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub struct Pinned { /// Pinned repositories. - pub repositories: HashSet, + #[cfg_attr( + feature = "schemars", + schemars(with = "std::collections::HashSet") + )] + pub repositories: IndexSet, }