1use std::sync::Arc;
2
3use askama::Template;
4use axum::{Extension, extract::Query, response::IntoResponse};
5use serde::Deserialize;
6use yoke::Yoke;
7
8use crate::{
9 Git,
10 git::DetailedTag,
11 into_response,
12 methods::{
13 filters,
14 repo::{Repository, RepositoryPath, Result},
15 },
16};
17
18#[derive(Deserialize)]
19pub struct UriQuery {
20 #[serde(rename = "h")]
21 name: Arc<str>,
22}
23
24#[derive(Template)]
25#[template(path = "repo/tag.html")]
26pub struct View {
27 repo: Repository,
28 tag: Yoke<DetailedTag<'static>, Vec<u8>>,
29 branch: Option<Arc<str>>,
30}
31
32pub async fn handle(
33 Extension(repo): Extension<Repository>,
34 Extension(RepositoryPath(repository_path)): Extension<RepositoryPath>,
35 Extension(git): Extension<Arc<Git>>,
36 Query(query): Query<UriQuery>,
37) -> Result<impl IntoResponse> {
38 let open_repo = git.repo(repository_path, Some(query.name.clone())).await?;
39 let tag = open_repo.tag_info().await?;
40
41 Ok(into_response(View {
42 repo,
43 tag,
44 branch: Some(query.name),
45 }))
46}