]>
git.cameronkatri.com Git - cgit.git/blob - ui-tag.c
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)
12 #include "ui-shared.h"
14 static void print_tag_content(char *buf
)
21 html("<div class='commit-subject'>");
22 p
= strchr(buf
, '\n');
28 html("<div class='commit-msg'>");
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
);
42 void cgit_print_tag(char *revname
)
44 struct strbuf fullref
= STRBUF_INIT
;
45 unsigned char sha1
[20];
51 revname
= ctx
.qry
.head
;
53 strbuf_addf(&fullref
, "refs/tags/%s", revname
);
54 if (get_sha1(fullref
.buf
, sha1
)) {
55 cgit_print_error_page(404, "Not found",
56 "Bad tag reference: %s", revname
);
59 obj
= parse_object(sha1
);
61 cgit_print_error_page(500, "Internal server error",
62 "Bad object id: %s", sha1_to_hex(sha1
));
65 if (obj
->type
== OBJ_TAG
) {
66 tag
= lookup_tag(sha1
);
67 if (!tag
|| parse_tag(tag
) || !(info
= cgit_parse_tag(tag
))) {
68 cgit_print_error_page(500, "Internal server error",
69 "Bad tag object: %s", revname
);
72 cgit_print_layout_start();
73 html("<table class='commit-info'>\n");
74 htmlf("<tr><td>tag name</td><td>");
76 htmlf(" (%s)</td></tr>\n", sha1_to_hex(sha1
));
77 if (info
->tagger_date
> 0) {
78 html("<tr><td>tag date</td><td>");
79 html_txt(show_date(info
->tagger_date
, info
->tagger_tz
,
80 cgit_date_mode(DATE_ISO8601
)));
84 html("<tr><td>tagged by</td><td>");
85 cgit_open_filter(ctx
.repo
->email_filter
, info
->tagger_email
, "tag");
86 html_txt(info
->tagger
);
87 if (info
->tagger_email
&& !ctx
.cfg
.noplainemail
) {
89 html_txt(info
->tagger_email
);
91 cgit_close_filter(ctx
.repo
->email_filter
);
94 html("<tr><td>tagged object</td><td class='sha1'>");
95 cgit_object_link(tag
->tagged
);
97 if (ctx
.repo
->snapshots
)
98 print_download_links(revname
);
100 print_tag_content(info
->msg
);
101 cgit_print_layout_end();
103 cgit_print_layout_start();
104 html("<table class='commit-info'>\n");
105 htmlf("<tr><td>tag name</td><td>");
107 html("</td></tr>\n");
108 html("<tr><td>Tagged object</td><td class='sha1'>");
109 cgit_object_link(obj
);
110 html("</td></tr>\n");
111 if (ctx
.repo
->snapshots
)
112 print_download_links(revname
);
114 cgit_print_layout_end();
118 strbuf_release(&fullref
);