···1616pub mod log;1717pub mod merge_check;1818pub mod set_default_branch;1919+pub mod tag;1920pub mod tags;2021pub mod tree;2122···5554impl_xrpc!(QUERY, get_default_branch, get_default_branch);5655impl_xrpc!(QUERY, languages, languages);5756impl_xrpc!(QUERY, log, log);5757+impl_xrpc!(QUERY, tag, tag);5858impl_xrpc!(QUERY, tags, tags);5959impl_xrpc!(QUERY, tree, tree);6060
···11+use core::error;22+33+use axum::Json;44+use serde::Serialize;55+66+use crate::extract::repository::XrpcRepository;77+use crate::lexicon::sh_tangled::repo::tag::Input;88+use crate::public::xrpc::XrpcError;99+use crate::public::xrpc::XrpcQuery;1010+use crate::public::xrpc::XrpcResult;1111+use crate::public::xrpc::sh_tangled::repo::tags::Tag;1212+1313+pub const LXM: &str = "/sh.tangled.repo.tag";1414+1515+/// Output of `sh.tangled.repo.tag` query.1616+///1717+/// This is not defined in the lexicon, but models what knotserver1818+/// currently produces.1919+#[derive(Debug, Serialize)]2020+pub struct Output {2121+ pub tag: Tag,2222+}2323+2424+#[tracing::instrument(target = "sh_tangled::repo::tags", err)]2525+pub async fn handle(2626+ XrpcRepository(repository): XrpcRepository,2727+ XrpcQuery(Input { repo, tag }): XrpcQuery<Input>,2828+) -> XrpcResult<Json<Output>> {2929+ tokio_rayon::spawn(move || {3030+ let repository = repository.to_thread_local();3131+ let reference = repository3232+ .find_reference(&format!("refs/tags/{tag}"))3333+ .map_err(TagNotFound)?;3434+ let tag = reference.try_into()?;3535+ Ok(Json(Output { tag }).into())3636+ })3737+ .await3838+}3939+4040+struct TagNotFound<E>(E);4141+4242+impl<E: error::Error> From<TagNotFound<E>> for XrpcError {4343+ fn from(value: TagNotFound<E>) -> Self {4444+ use axum::http::StatusCode;4545+ Self::new(StatusCode::NOT_FOUND, "TagNotFound", value.0.to_string())4646+ }4747+}
+1
crates/gordian-lexicon/src/sh_tangled/repo.rs
···1313pub mod merge_check;1414pub mod pull;1515pub mod set_default_branch;1616+pub mod tag;1617pub mod tags;1718pub mod tree;1819
+14
crates/gordian-lexicon/src/sh_tangled/repo/tag.rs
···11+//!22+//! <https://tangled.org/@tangled.org/core/blob/master/lexicons/repo/tag.json>33+44+/// Parameters for the `sh.tangled.repo.tag` query.55+///66+/// <https://tangled.org/@tangled.org/core/blob/master/lexicons/repo/tag.json>77+#[derive(Debug, serde::Deserialize)]88+pub struct Input {99+ /// Repository identifier in the format `did:plc:.../repoName`1010+ pub repo: String,1111+1212+ /// Name of tag, such as v1.3.01313+ pub tag: String,1414+}