]> gitweb.ps.run Git - ps-cgit/blob - ui-tag.c
ui-tag: show the taggers email
[ps-cgit] / ui-tag.c
1 /* ui-tag.c: display a tag
2  *
3  * Copyright (C) 2007 Lars Hjemli
4  *
5  * Licensed under GNU General Public License v2
6  *   (see COPYING for full license text)
7  */
8
9 #include "cgit.h"
10 #include "html.h"
11 #include "ui-shared.h"
12
13 static void print_tag_content(char *buf)
14 {
15         char *p;
16
17         if (!buf)
18                 return;
19
20         html("<div class='commit-subject'>");
21         p = strchr(buf, '\n');
22         if (p)
23                 *p = '\0';
24         html_txt(buf);
25         html("</div>");
26         if (p) {
27                 html("<div class='commit-msg'>");
28                 html_txt(++p);
29                 html("</div>");
30         }
31 }
32
33 void cgit_print_tag(char *revname)
34 {
35         unsigned char sha1[20];
36         struct object *obj;
37         struct tag *tag;
38         struct taginfo *info;
39
40         if (get_sha1(revname, sha1)) {
41                 cgit_print_error(fmt("Bad tag reference: %s", revname));
42                 return;
43         }
44         obj = parse_object(sha1);
45         if (!obj) {
46                 cgit_print_error(fmt("Bad object id: %s", sha1_to_hex(sha1)));
47                 return;
48         }
49         if (obj->type == OBJ_TAG) {
50                 tag = lookup_tag(sha1);
51                 if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) {
52                         cgit_print_error(fmt("Bad tag object: %s", revname));
53                         return;
54                 }
55                 html("<table class='commit-info'>\n");
56                 htmlf("<tr><td>Tag name</td><td>%s (%s)</td></tr>\n",
57                       revname, sha1_to_hex(sha1));
58                 if (info->tagger_date > 0) {
59                         html("<tr><td>Tag date</td><td>");
60                         cgit_print_date(info->tagger_date, FMT_LONGDATE, ctx.cfg.local_time);
61                         html("</td></tr>\n");
62                 }
63                 if (info->tagger) {
64                         html("<tr><td>Tagged by</td><td>");
65                         html_txt(info->tagger);
66                         if (info->tagger_email) {
67                                 html(" ");
68                                 html_txt(info->tagger_email);
69                         }
70                         html("</td></tr>\n");
71                 }
72                 html("<tr><td>Tagged object</td><td>");
73                 cgit_object_link(tag->tagged);
74                 html("</td></tr>\n");
75                 html("</table>\n");
76                 print_tag_content(info->msg);
77         }
78         return;
79 }