Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
radicle: Keep pinned repos ordered in config
Tobias Hunger committed 9 months ago
commit 7c4b71ab8205a69a04ee9e9242288c864e6c7c33
parent 1fa30e2e88b58e48e8fcadfe416b65a85f916b4a
4 files changed +12 -4
modified 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",
modified 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.
modified 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"] }
modified 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<RepoId>,
+
    #[cfg_attr(
+
        feature = "schemars",
+
        schemars(with = "std::collections::HashSet<RepoId>")
+
    )]
+
    pub repositories: IndexSet<RepoId>,
}