|
diff --git a/ui-tag.c b/ui-tag.c index cd353c2..39e4cb8 100644 --- a/ ui-tag.c+++ b/ ui-tag.c |
|
@@ -1,104 +1,104 @@ |
1 | /* ui-tag.c: display a tag |
1 | /* ui-tag.c: display a tag |
2 | * |
2 | * |
3 | * Copyright (C) 2007 Lars Hjemli |
3 | * Copyright (C) 2007 Lars Hjemli |
4 | * |
4 | * |
5 | * Licensed under GNU General Public License v2 |
5 | * Licensed under GNU General Public License v2 |
6 | * (see COPYING for full license text) |
6 | * (see COPYING for full license text) |
7 | */ |
7 | */ |
8 | |
8 | |
9 | #include "cgit.h" |
9 | #include "cgit.h" |
10 | #include "html.h" |
10 | #include "html.h" |
11 | #include "ui-shared.h" |
11 | #include "ui-shared.h" |
12 | |
12 | |
13 | static void print_tag_content(char *buf) |
13 | static void print_tag_content(char *buf) |
14 | { |
14 | { |
15 | char *p; |
15 | char *p; |
16 | |
16 | |
17 | if (!buf) |
17 | if (!buf) |
18 | return; |
18 | return; |
19 | |
19 | |
20 | html("<div class='commit-subject'>"); |
20 | html("<div class='commit-subject'>"); |
21 | p = strchr(buf, '\n'); |
21 | p = strchr(buf, '\n'); |
22 | if (p) |
22 | if (p) |
23 | *p = '\0'; |
23 | *p = '\0'; |
24 | html_txt(buf); |
24 | html_txt(buf); |
25 | html("</div>"); |
25 | html("</div>"); |
26 | if (p) { |
26 | if (p) { |
27 | html("<div class='commit-msg'>"); |
27 | html("<div class='commit-msg'>"); |
28 | html_txt(++p); |
28 | html_txt(++p); |
29 | html("</div>"); |
29 | html("</div>"); |
30 | } |
30 | } |
31 | } |
31 | } |
32 | |
32 | |
33 | void print_download_links(char *revname) |
33 | void print_download_links(char *revname) |
34 | { |
34 | { |
35 | html("<tr><th>download</th><td class='sha1'>"); |
35 | html("<tr><th>download</th><td class='sha1'>"); |
36 | cgit_print_snapshot_links(ctx.qry.repo, ctx.qry.head, |
36 | cgit_print_snapshot_links(ctx.qry.repo, ctx.qry.head, |
37 | revname, ctx.repo->snapshots); |
37 | revname, ctx.repo->snapshots); |
38 | html("</td></tr>"); |
38 | html("</td></tr>"); |
39 | } |
39 | } |
40 | |
40 | |
41 | void cgit_print_tag(char *revname) |
41 | void cgit_print_tag(char *revname) |
42 | { |
42 | { |
43 | unsigned char sha1[20]; |
43 | unsigned char sha1[20]; |
44 | struct object *obj; |
44 | struct object *obj; |
45 | struct tag *tag; |
45 | struct tag *tag; |
46 | struct taginfo *info; |
46 | struct taginfo *info; |
47 | |
47 | |
48 | if (!revname) |
48 | if (!revname) |
49 | revname = ctx.qry.head; |
49 | revname = ctx.qry.head; |
50 | |
50 | |
51 | if (get_sha1(fmt("refs/tags/%s", revname), sha1)) { |
51 | if (get_sha1(fmt("refs/tags/%s", revname), sha1)) { |
52 | cgit_print_error(fmt("Bad tag reference: %s", revname)); |
52 | cgit_print_error(fmt("Bad tag reference: %s", revname)); |
53 | return; |
53 | return; |
54 | } |
54 | } |
55 | obj = parse_object(sha1); |
55 | obj = parse_object(sha1); |
56 | if (!obj) { |
56 | if (!obj) { |
57 | cgit_print_error(fmt("Bad object id: %s", sha1_to_hex(sha1))); |
57 | cgit_print_error(fmt("Bad object id: %s", sha1_to_hex(sha1))); |
58 | return; |
58 | return; |
59 | } |
59 | } |
60 | if (obj->type == OBJ_TAG) { |
60 | if (obj->type == OBJ_TAG) { |
61 | tag = lookup_tag(sha1); |
61 | tag = lookup_tag(sha1); |
62 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) { |
62 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) { |
63 | cgit_print_error(fmt("Bad tag object: %s", revname)); |
63 | cgit_print_error(fmt("Bad tag object: %s", revname)); |
64 | return; |
64 | return; |
65 | } |
65 | } |
66 | html("<table class='commit-info'>\n"); |
66 | html("<table class='commit-info'>\n"); |
67 | htmlf("<tr><td>Tag name</td><td>"); |
67 | htmlf("<tr><td>tag name</td><td>"); |
68 | html_txt(revname); |
68 | html_txt(revname); |
69 | htmlf(" (%s)</td></tr>\n", sha1_to_hex(sha1)); |
69 | htmlf(" (%s)</td></tr>\n", sha1_to_hex(sha1)); |
70 | if (info->tagger_date > 0) { |
70 | if (info->tagger_date > 0) { |
71 | html("<tr><td>Tag date</td><td>"); |
71 | html("<tr><td>tag date</td><td>"); |
72 | cgit_print_date(info->tagger_date, FMT_LONGDATE, ctx.cfg.local_time); |
72 | cgit_print_date(info->tagger_date, FMT_LONGDATE, ctx.cfg.local_time); |
73 | html("</td></tr>\n"); |
73 | html("</td></tr>\n"); |
74 | } |
74 | } |
75 | if (info->tagger) { |
75 | if (info->tagger) { |
76 | html("<tr><td>Tagged by</td><td>"); |
76 | html("<tr><td>tagged by</td><td>"); |
77 | html_txt(info->tagger); |
77 | html_txt(info->tagger); |
78 | if (info->tagger_email && !ctx.cfg.noplainemail) { |
78 | if (info->tagger_email && !ctx.cfg.noplainemail) { |
79 | html(" "); |
79 | html(" "); |
80 | html_txt(info->tagger_email); |
80 | html_txt(info->tagger_email); |
81 | } |
81 | } |
82 | html("</td></tr>\n"); |
82 | html("</td></tr>\n"); |
83 | } |
83 | } |
84 | html("<tr><td>Tagged object</td><td>"); |
84 | html("<tr><td>tagged object</td><td class='sha1'>"); |
85 | cgit_object_link(tag->tagged); |
85 | cgit_object_link(tag->tagged); |
86 | html("</td></tr>\n"); |
86 | html("</td></tr>\n"); |
87 | if (ctx.repo->snapshots) |
87 | if (ctx.repo->snapshots) |
88 | print_download_links(revname); |
88 | print_download_links(revname); |
89 | html("</table>\n"); |
89 | html("</table>\n"); |
90 | print_tag_content(info->msg); |
90 | print_tag_content(info->msg); |
91 | } else { |
91 | } else { |
92 | html("<table class='commit-info'>\n"); |
92 | html("<table class='commit-info'>\n"); |
93 | htmlf("<tr><td>Tag name</td><td>"); |
93 | htmlf("<tr><td>tag name</td><td>"); |
94 | html_txt(revname); |
94 | html_txt(revname); |
95 | html("</td></tr>\n"); |
95 | html("</td></tr>\n"); |
96 | html("<tr><td>Tagged object</td><td>"); |
96 | html("<tr><td>Tagged object</td><td class='sha1'>"); |
97 | cgit_object_link(obj); |
97 | cgit_object_link(obj); |
98 | html("</td></tr>\n"); |
98 | html("</td></tr>\n"); |
99 | if (ctx.repo->snapshots) |
99 | if (ctx.repo->snapshots) |
100 | print_download_links(revname); |
100 | print_download_links(revname); |
101 | html("</table>\n"); |
101 | html("</table>\n"); |
102 | } |
102 | } |
103 | return; |
103 | return; |
104 | } |
104 | } |
|