radicle: Keep pinned repos ordered in config

Do not return them in a random order in radicle-httpd,
so that we can have them in a defined order in
radicle-explorer.
This commit is contained in:
Tobias Hunger 2025-07-01 07:43:27 +00:00 committed by Fintan Halpenny
parent 1fa30e2e88
commit 7c4b71ab82
4 changed files with 12 additions and 4 deletions

2
Cargo.lock generated
View File

@ -1719,6 +1719,7 @@ checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26"
dependencies = [
"equivalent",
"hashbrown",
"serde",
]
[[package]]
@ -2479,6 +2480,7 @@ dependencies = [
"fast-glob",
"fastrand",
"git2",
"indexmap",
"jsonschema",
"libc",
"localtime",

View File

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

View File

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

View File

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