diff options
author | Lars Hjemli | 2007-07-22 23:42:55 +0200 |
---|---|---|
committer | Lars Hjemli | 2007-07-22 23:44:57 +0200 |
commit | 4e9107abfe8d3edff17826875b417bcf40dc7390 (patch) | |
tree | 96cfafa9b8838f34e1363ee3019eae64a6229b30 /ui-tag.c | |
parent | 71ebcbe23ab548e5c0ad40aa8be5741654ed3201 (diff) | |
download | cgit-4e9107abfe8d3edff17826875b417bcf40dc7390.tar.gz cgit-4e9107abfe8d3edff17826875b417bcf40dc7390.tar.bz2 cgit-4e9107abfe8d3edff17826875b417bcf40dc7390.zip |
Add ui-tag.c
This file implements the tag-command, i.e. printing of annotated tags.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'ui-tag.c')
-rw-r--r-- | ui-tag.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/ui-tag.c b/ui-tag.c new file mode 100644 index 0000000..a6989ff --- /dev/null +++ b/ui-tag.c | |||
@@ -0,0 +1,74 @@ | |||
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 | |||
11 | |||
12 | static void print_tag_content(char *buf) | ||
13 | { | ||
14 | char *p; | ||
15 | |||
16 | if (!buf) | ||
17 | return; | ||
18 | |||
19 | html("<div class='commit-subject'>"); | ||
20 | p = strchr(buf, '\n'); | ||
21 | if (p) | ||
22 | *p = '\0'; | ||
23 | html_txt(buf); | ||
24 | html("</div>"); | ||
25 | if (p) { | ||
26 | html("<div class='commit-msg'>"); | ||
27 | html_txt(++p); | ||
28 | html("</div>"); | ||
29 | } | ||
30 | } | ||
31 | |||
32 | void cgit_print_tag(char *revname) | ||
33 | { | ||
34 | unsigned char sha1[20]; | ||
35 | struct object *obj; | ||
36 | struct tag *tag; | ||
37 | struct taginfo *info; | ||
38 | |||
39 | if (get_sha1(revname, sha1)) { | ||
40 | cgit_print_error(fmt("Bad tag reference: %s", revname)); | ||
41 | return; | ||
42 | } | ||
43 | obj = parse_object(sha1); | ||
44 | if (!obj) { | ||
45 | cgit_print_error(fmt("Bad object id: %s", sha1_to_hex(sha1))); | ||
46 | return; | ||
47 | } | ||
48 | if (obj->type == OBJ_TAG) { | ||
49 | tag = lookup_tag(sha1); | ||
50 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) { | ||
51 | cgit_print_error(fmt("Bad tag object: %s", revname)); | ||
52 | return; | ||
53 | } | ||
54 | html("<table class='commit-info'>\n"); | ||
55 | htmlf("<tr><td>Tag name</td><td>%s (%s)</td></tr>\n", | ||
56 | revname, sha1_to_hex(sha1)); | ||
57 | if (info->tagger_date > 0) { | ||
58 | html("<tr><td>Tag date</td><td>"); | ||
59 | cgit_print_date(info->tagger_date, FMT_LONGDATE); | ||
60 | html("</td><tr>\n"); | ||
61 | } | ||
62 | if (info->tagger) { | ||
63 | html("<tr><td>Tagged by</td><td>"); | ||
64 | html_txt(info->tagger); | ||
65 | html("</td></tr>\n"); | ||
66 | } | ||
67 | html("<tr><td>Tagged object</td><td>"); | ||
68 | cgit_object_link(tag->tagged); | ||
69 | html("</td></tr>\n"); | ||
70 | html("</table>\n"); | ||
71 | print_tag_content(info->msg); | ||
72 | } | ||
73 | return; | ||
74 | } | ||