Example #1
0
void show_commit_decorations(struct commit *commit)
{
	struct name_decoration *deco;
	static char buf[1024];

	buf[sizeof(buf) - 1] = 0;
	deco = lookup_decoration(&name_decoration, &commit->object);
	html("<span class='decoration'>");
	while (deco) {
		if (!prefixcmp(deco->name, "refs/heads/")) {
			strncpy(buf, deco->name + 11, sizeof(buf) - 1);
			cgit_log_link(buf, NULL, "branch-deco", buf, NULL,
				      ctx.qry.vpath, 0, NULL, NULL,
				      ctx.qry.showmsg);
		}
		else if (!prefixcmp(deco->name, "tag: refs/tags/")) {
			strncpy(buf, deco->name + 15, sizeof(buf) - 1);
			cgit_tag_link(buf, NULL, "tag-deco", ctx.qry.head, buf);
		}
		else if (!prefixcmp(deco->name, "refs/tags/")) {
			strncpy(buf, deco->name + 10, sizeof(buf) - 1);
			cgit_tag_link(buf, NULL, "tag-deco", ctx.qry.head, buf);
		}
		else if (!prefixcmp(deco->name, "refs/remotes/")) {
			if (!ctx.repo->enable_remote_branches)
				goto next;
			strncpy(buf, deco->name + 13, sizeof(buf) - 1);
			cgit_log_link(buf, NULL, "remote-deco", NULL,
				      sha1_to_hex(commit->object.sha1),
				      ctx.qry.vpath, 0, NULL, NULL,
				      ctx.qry.showmsg);
		}
		else {
			strncpy(buf, deco->name, sizeof(buf) - 1);
			cgit_commit_link(buf, NULL, "deco", ctx.qry.head,
					 sha1_to_hex(commit->object.sha1),
					 ctx.qry.vpath, 0);
		}
next:
		deco = deco->next;
	}
	html("</span>");
}
Example #2
0
static int print_tag(struct refinfo *ref)
{
	struct tag *tag = NULL;
	struct taginfo *info = NULL;
	char *name = (char *)ref->refname;
	struct object *obj = ref->object;

	if (obj->type == OBJ_TAG) {
		tag = (struct tag *)obj;
		obj = tag->tagged;
		info = ref->tag;
		if (!tag || !info)
			return 1;
	}

	html("<tr><td>");
	cgit_tag_link(name, NULL, NULL, ctx.qry.head, name);
	html("</td><td>");
	if (ctx.repo->snapshots && (obj->type == OBJ_COMMIT))
		print_tag_downloads(ctx.repo, name);
	else
		cgit_object_link(obj);
	html("</td><td>");
	if (info) {
		if (info->tagger) {
			cgit_open_filter(ctx.repo->email_filter, info->tagger_email, "refs");
			html_txt(info->tagger);
			cgit_close_filter(ctx.repo->email_filter);
		}
	} else if (ref->object->type == OBJ_COMMIT) {
		cgit_open_filter(ctx.repo->email_filter, ref->commit->author_email, "refs");
		html_txt(ref->commit->author);
		cgit_close_filter(ctx.repo->email_filter);
	}
	html("</td><td colspan='2'>");
	if (info) {
		if (info->tagger_date > 0)
			cgit_print_age(info->tagger_date, -1, NULL);
	} else if (ref->object->type == OBJ_COMMIT) {
		cgit_print_age(ref->commit->commit->date, -1, NULL);
	}
	html("</td></tr>\n");

	return 0;
}
Example #3
0
static int print_tag(struct refinfo *ref)
{
	struct tag *tag;
	struct taginfo *info;
	char *name = (char *)ref->refname;

	if (ref->object->type == OBJ_TAG) {
		tag = (struct tag *)ref->object;
		info = ref->tag;
		if (!tag || !info)
			return 1;
		html("<tr><td>");
		cgit_tag_link(name, NULL, NULL, ctx.qry.head, name);
		html("</td><td>");
		if (ctx.repo->snapshots && (tag->tagged->type == OBJ_COMMIT))
			print_tag_downloads(ctx.repo, name);
		else
			cgit_object_link(tag->tagged);
		html("</td><td>");
		if (info->tagger)
			html(info->tagger);
		html("</td><td colspan='2'>");
		if (info->tagger_date > 0)
			cgit_print_age(info->tagger_date, -1, NULL);
		html("</td></tr>\n");
	} else {
		if (!header)
			print_tag_header();
		html("<tr><td>");
		html_txt(name);
		html("</td><td>");
		if (ctx.repo->snapshots && (tag->tagged->type == OBJ_COMMIT))
			print_tag_downloads(ctx.repo, name);
		else
			cgit_object_link(ref->object);
		html("</td></tr>\n");
	}
	return 0;
}