1 /* ui-tag.c: display a tag
3 * Copyright (C) 2006-2014 cgit Development Team <cgit@lists.zx2c4.com>
5 * Licensed under GNU General Public License v2
6 * (see COPYING for full license text)
9 #define USE_THE_REPOSITORY_VARIABLE
14 #include "ui-shared.h"
16 static void print_tag_content(char *buf)
23 html("<div class='commit-subject'>");
24 p = strchr(buf, '\n');
30 html("<div class='commit-msg'>");
36 static void print_download_links(char *revname)
38 html("<tr><th>download</th><td class='oid'>");
39 cgit_print_snapshot_links(ctx.repo, revname, "<br/>");
43 void cgit_print_tag(char *revname)
45 struct strbuf fullref = STRBUF_INIT;
50 revname = ctx.qry.head;
52 strbuf_addf(&fullref, "refs/tags/%s", revname);
53 if (repo_get_oid(the_repository, fullref.buf, &oid)) {
54 cgit_print_error_page(404, "Not found",
55 "Bad tag reference: %s", revname);
58 obj = parse_object(the_repository, &oid);
60 cgit_print_error_page(500, "Internal server error",
61 "Bad object id: %s", oid_to_hex(&oid));
64 if (obj->type == OBJ_TAG) {
68 tag = lookup_tag(the_repository, &oid);
69 if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) {
70 cgit_print_error_page(500, "Internal server error",
71 "Bad tag object: %s", revname);
74 cgit_print_layout_start();
75 html("<table class='commit-info'>\n");
76 html("<tr><td>tag name</td><td>");
78 htmlf(" (%s)</td></tr>\n", oid_to_hex(&oid));
79 if (info->tagger_date > 0) {
80 html("<tr><td>tag date</td><td>");
81 html_txt(show_date(info->tagger_date, info->tagger_tz,
82 cgit_date_mode(DATE_ISO8601)));
86 html("<tr><td>tagged by</td><td>");
87 cgit_open_filter(ctx.repo->email_filter, info->tagger_email, "tag");
88 html_txt(info->tagger);
89 if (info->tagger_email && !ctx.cfg.noplainemail) {
91 html_txt(info->tagger_email);
93 cgit_close_filter(ctx.repo->email_filter);
96 html("<tr><td>tagged object</td><td class='oid'>");
97 cgit_object_link(tag->tagged);
99 if (ctx.repo->snapshots)
100 print_download_links(revname);
102 print_tag_content(info->msg);
103 cgit_print_layout_end();
104 cgit_free_taginfo(info);
106 cgit_print_layout_start();
107 html("<table class='commit-info'>\n");
108 html("<tr><td>tag name</td><td>");
110 html("</td></tr>\n");
111 html("<tr><td>tagged object</td><td class='oid'>");
112 cgit_object_link(obj);
113 html("</td></tr>\n");
114 if (ctx.repo->snapshots)
115 print_download_links(revname);
117 cgit_print_layout_end();
121 strbuf_release(&fullref);