| 1 | use crate::{git::tag::TaggedObject, prelude::*, routes::PageQuery}; |
| 2 | |
| 3 | #[derive(Template)] |
| 4 | #[template(path = "repository/tag.html")] |
| 5 | struct TagPage<'repo> { |
| 6 | repo: &'repo Repository, |
| 7 | branch_names: Vec<String>, |
| 8 | current_ref: Ref, |
| 9 | tag: Tag, |
| 10 | query: web::Query<PageQuery>, |
| 11 | } |
| 12 | |
| 13 | #[get("/{repo}/tag/")] |
| 14 | pub async fn page( |
| 15 | path: web::Path<String>, |
| 16 | query: web::Query<PageQuery>, |
| 17 | data: web::Data<App>, |
| 18 | ) -> Result<HttpResponse, Error> { |
| 19 | let repo = data.get_repo(&path)?; |
| 20 | let gix_repo = repo.gix(); |
| 21 | |
| 22 | let current_ref = Ref::resolve(&repo, &query)?; |
| 23 | let branch_names = repo.branch_names()?; |
| 24 | let tag = if let Some(ref head) = query.head { |
| 25 | repo.find_tag(head)? |
| 26 | } else { |
| 27 | let reference = gix_repo.find_reference(&format!("heads/{}", current_ref.name))?; |
| 28 | Tag::from_gix(reference)? |
| 29 | }; |
| 30 | |
| 31 | render_html(&TagPage { |
| 32 | repo: &repo, |
| 33 | branch_names, |
| 34 | current_ref, |
| 35 | tag, |
| 36 | query, |
| 37 | }) |
| 38 | } |
