Bump version.
[cgit.git] / ui-tag.c
blobc1d173836357a017538db1dd7028b265acc04895
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)
7 */
9 #include "cgit.h"
10 #include "ui-tag.h"
11 #include "html.h"
12 #include "ui-shared.h"
14 static void print_tag_content(char *buf)
16 char *p;
18 if (!buf)
19 return;
21 html("<div class='commit-subject'>");
22 p = strchr(buf, '\n');
23 if (p)
24 *p = '\0';
25 html_txt(buf);
26 html("</div>");
27 if (p) {
28 html("<div class='commit-msg'>");
29 html_txt(++p);
30 html("</div>");
34 static void print_download_links(char *revname)
36 html("<tr><th>download</th><td class='sha1'>");
37 cgit_print_snapshot_links(ctx.qry.repo, ctx.qry.head,
38 revname, ctx.repo->snapshots);
39 html("</td></tr>");
42 void cgit_print_tag(char *revname)
44 struct strbuf fullref = STRBUF_INIT;
45 unsigned char sha1[20];
46 struct object *obj;
47 struct tag *tag;
48 struct taginfo *info;
50 if (!revname)
51 revname = ctx.qry.head;
53 strbuf_addf(&fullref, "refs/tags/%s", revname);
54 if (get_sha1(fullref.buf, sha1)) {
55 cgit_print_error("Bad tag reference: %s", revname);
56 goto cleanup;
58 obj = parse_object(sha1);
59 if (!obj) {
60 cgit_print_error("Bad object id: %s", sha1_to_hex(sha1));
61 goto cleanup;
63 if (obj->type == OBJ_TAG) {
64 tag = lookup_tag(sha1);
65 if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) {
66 cgit_print_error("Bad tag object: %s", revname);
67 goto cleanup;
69 html("<table class='commit-info'>\n");
70 htmlf("<tr><td>tag name</td><td>");
71 html_txt(revname);
72 htmlf(" (%s)</td></tr>\n", sha1_to_hex(sha1));
73 if (info->tagger_date > 0) {
74 html("<tr><td>tag date</td><td>");
75 cgit_print_date(info->tagger_date, FMT_LONGDATE, ctx.cfg.local_time);
76 html("</td></tr>\n");
78 if (info->tagger) {
79 html("<tr><td>tagged by</td><td>");
80 cgit_open_filter(ctx.repo->email_filter, info->tagger_email, "tag");
81 html_txt(info->tagger);
82 if (info->tagger_email && !ctx.cfg.noplainemail) {
83 html(" ");
84 html_txt(info->tagger_email);
86 cgit_close_filter(ctx.repo->email_filter);
87 html("</td></tr>\n");
89 html("<tr><td>tagged object</td><td class='sha1'>");
90 cgit_object_link(tag->tagged);
91 html("</td></tr>\n");
92 if (ctx.repo->snapshots)
93 print_download_links(revname);
94 html("</table>\n");
95 print_tag_content(info->msg);
96 } else {
97 html("<table class='commit-info'>\n");
98 htmlf("<tr><td>tag name</td><td>");
99 html_txt(revname);
100 html("</td></tr>\n");
101 html("<tr><td>Tagged object</td><td class='sha1'>");
102 cgit_object_link(obj);
103 html("</td></tr>\n");
104 if (ctx.repo->snapshots)
105 print_download_links(revname);
106 html("</table>\n");
109 cleanup:
110 strbuf_release(&fullref);