2 cehtehs git web frontend
5 2007, 2008, Christian Thaeter <ct@pipapo.org>
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the
10 License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 #define SHA1_HEADER <openssl/sha.h>
30 #include "git/cache.h"
32 //#include "git/commit.h"
39 struct webgit_repo_info* repo;
48 webgit_tag_link (struct webgit_repo_info* repo, const char* tag, int count, Html text)
52 html_attr ("href", html(
53 html_fmt ("%s?repo=%s&action=tag",
54 repo->query->request->script_name,
56 tag ? html_fmt("&ref=%s", tag) : html (),
57 count > 0 ? html_fmt("&count=%d",
67 show_tag_ref (const char *refname, const unsigned char *sha1, int flags, void *data)
70 struct tag_context* ctx = (struct tag_context*) data;
71 struct webgit_repo_info* repo = ctx->repo;
75 if (!strcmp (ctx->start, refname))
83 /* displayed query->count lines, finish */
84 html_list_append (ctx->cont,
93 struct tag* tag = lookup_tag (sha1);
95 enum object_type type;
99 buffer = read_sha1_file (tag->object.sha1, &type, &size);
101 if (!tag->object.parsed)
102 parse_tag_buffer (tag, buffer, size);
105 webgit_object_tag_date_parse (buffer, size, NULL);
108 snprintf (tagref, 256, "refs/tags/%s", refname);
110 struct object* derefed = deref_tag ((struct object*)tag, NULL, 0);
112 html_list_append (ctx->table,
117 webgit_object_link (repo->query,
118 repo->name, strlen(repo->name),
119 sha1_to_hex (sha1), 40,
122 html_strndup (refname, SIZE_MAX))
126 webgit_object_link (repo->query,
127 repo->name, strlen(repo->name),
128 sha1_to_hex (derefed->sha1), 40,
131 webgit_pretty_age (repo->query->now - date))
136 webgit_object_tag_name_parse (buffer, size),
137 webgit_object_tag_email_parse (buffer, size)
142 webgit_object_tag_header_parse (buffer, size)
146 webgit_log_link (repo->query,
152 webgit_object_link (repo->query,
153 repo->name, strlen(repo->name),
154 sha1_to_hex (derefed->sha1), 40,
167 webgit_tag_table (struct webgit_repo_info* repo, const char* head, int count)
169 struct tag_context ctx;
171 ctx.table = html_list ();
172 ctx.cont = html_list ();
176 for_each_tag_ref (show_tag_ref, &ctx);
178 return html (html (html_tag ("table"), ctx.table), ctx.cont);