From 7721ec50853daaafd2999337d9ae198abcea9a1c Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Tue, 15 Sep 2026 18:05:47 -1000 Subject: Lay the tag table out like the commit table --- assets/cgit.css | 1 - source/ui-tag.c | 78 ++++++++++++++++++++++++++++++++---------------------- tests/t0113-tag.sh | 46 ++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 32 deletions(-) create mode 100755 tests/t0113-tag.sh diff --git a/assets/cgit.css b/assets/cgit.css index 6f4fba3..c141e3f 100644 --- a/assets/cgit.css +++ b/assets/cgit.css @@ -975,7 +975,6 @@ div#cgit table.ssdiff td.truncated { div#cgit .oid { font-family: var(--font-mono); - font-size: 90%; overflow-wrap: anywhere; } diff --git a/source/ui-tag.c b/source/ui-tag.c index ec8cd54..02fbfc7 100644 --- a/source/ui-tag.c +++ b/source/ui-tag.c @@ -17,27 +17,62 @@ #include "ui-shared.h" #include "ui-tag.h" +// The rows share the commit page's three column layout, so a single value +// spans the name and date columns of the tagger row. +static void print_tag_row(const char *revname, const struct object_id *oid) +{ + html("tag"); + html_txt(revname); + if (oid) + htmlf(" (%s)", oid_to_hex(oid)); + html("\n"); +} + static void print_object_row(struct object *obj) { - html("tagged object"); + html("object"); cgit_object_link(obj); html("\n"); } static void print_download_row(const char *revname) { - html("download"); + html("download"); cgit_print_snapshot_links(ctx.repo, revname, "
"); html("\n"); } +static void print_tagger_row(struct taginfo *info) +{ + html("tagger"); + // A tag can carry a tagger with no address, and a filter must not be + // handed a NULL argument. + cgit_open_filter(ctx.repo->email_filter, info->tagger_email ? info->tagger_email : "", "tag"); + html_txt(info->tagger); + if (info->tagger_email && ctx.cfg.enable_plain_email) { + html(" "); + html_txt(info->tagger_email); + } + cgit_close_filter(ctx.repo->email_filter); + html(""); + if (info->tagger_date > 0) { + html(""); + } + html("\n"); +} + /* * Cutting the subject out terminates the message in place, which is safe only - * because the caller frees it straight after. + * because the caller frees it straight after. The blank lines between the + * subject and the body are skipped, as the commit page skips them. */ static void print_message(char *msg) { - char *newline; + char *newline, *body; if (!msg) return; @@ -49,8 +84,11 @@ static void print_message(char *msg) html_txt(msg); html(""); if (newline) { + body = newline + 1; + while (*body == '\n') + body++; html("
"); - html_txt(newline + 1); + html_txt(body); html("
"); } } @@ -68,29 +106,9 @@ static void print_annotated_tag(const char *revname, const struct object_id *oid cgit_print_layout_start(); html("\n"); - html("\n", oid_to_hex(oid)); - if (info->tagger_date > 0) { - html("\n"); - } - if (info->tagger) { - html("\n"); - } + if (info->tagger) + print_tagger_row(info); + print_tag_row(revname, oid); print_object_row(tag->tagged); if (ctx.repo->snapshots) print_download_row(revname); @@ -104,9 +122,7 @@ static void print_lightweight_tag(const char *revname, struct object *obj) { cgit_print_layout_start(); html("
tag name"); - html_txt(revname); - htmlf(" (%s)
tag date
tagged by"); - // A tag can carry a tagger with no address, and a filter must - // not be handed a NULL argument. - cgit_open_filter(ctx.repo->email_filter, info->tagger_email ? info->tagger_email : "", "tag"); - html_txt(info->tagger); - if (info->tagger_email && ctx.cfg.enable_plain_email) { - html(" "); - html_txt(info->tagger_email); - } - cgit_close_filter(ctx.repo->email_filter); - html("
\n"); - html("\n"); + print_tag_row(revname, NULL); print_object_row(obj); if (ctx.repo->snapshots) print_download_row(revname); diff --git a/tests/t0113-tag.sh b/tests/t0113-tag.sh new file mode 100755 index 0000000..12ad1b4 --- /dev/null +++ b/tests/t0113-tag.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +# The tag page. An annotated tag gets the same three column table as the +# commit page, with the tagger and date on one row and the tag, object and +# download rows spanning the rest, and its message follows with no blank +# line between subject and body. A lightweight tag gets the shorter table. + +test_description='Check content on tag page' +. ./setup.sh + +test_expect_success 'create an annotated and a lightweight tag' ' + ( + cd repos/foo && + git tag -a -m "Annotated tag + +Release notes over +two lines." v1.0 && + git tag light + ) +' + +test_expect_success 'generate foo/tag/?h=v1.0' 'cgit_url "foo/tag/&h=v1.0" >tmp' + +test_expect_success 'find the tagger row with its date' ' + grep "" tmp && + grep "" tmp && + grep "
tag name"); - html_txt(revname); - html("
taggerC O Mitter <committer@example.com>tagv1.0 ([0-9a-f]*)
objectdownload" tmp +' + +test_expect_success 'the message follows with no blank line before the body' ' + tr -d "\n" flat && + grep "
Annotated tag
Release notes overtwo lines.
" flat +' + +test_expect_success 'a lightweight tag gets the shorter table' ' + cgit_url "foo/tag/&h=light" >tmp && + grep "
taglight
objecttagger" tmp +' + +test_done -- cgit v2.8.0