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