feat: add helper program to output node events

This mostly useful for development, but serves as a way to show a
valid JSON representation of a node event.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
This commit is contained in:
Lars Wirzenius
2024-05-07 19:26:40 +03:00
parent 1a44586eac
commit bb24029ff5
+33
View File
@@ -0,0 +1,33 @@
use std::str::FromStr;
use radicle::git::{Oid, RefString};
use radicle::{
node::Event,
prelude::{NodeId, RepoId},
storage::RefUpdate,
};
fn main() {
let event = Event::RefsFetched {
remote: NodeId::from_str("z6MkgEMYod7Hxfy9qCvDv5hYHkZ4ciWmLFgfvm3Wn1b2w2FV").unwrap(),
rid: RepoId::from_urn("rad:zwTxygwuz5LDGBq255RA2CbNGrz8").unwrap(),
updated: vec![RefUpdate::Skipped {
name: RefString::try_from("shutdown").expect("create name"),
oid: Oid::try_from("0").unwrap(),
}],
};
println!("{}", serde_json::to_string(&event).unwrap());
println!();
let event = Event::RefsFetched {
remote: NodeId::from_str("z6MkgEMYod7Hxfy9qCvDv5hYHkZ4ciWmLFgfvm3Wn1b2w2FV").unwrap(),
rid: RepoId::from_urn("rad:zwTxygwuz5LDGBq255RA2CbNGrz8").unwrap(),
updated: vec![RefUpdate::Updated {
name: RefString::try_from("shutdown").expect("create name"),
old: Oid::try_from("0").unwrap(),
new: Oid::try_from("0").unwrap(),
}],
};
println!("{}", serde_json::to_string(&event).unwrap());
}