diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Lay the tag table out like the commit table
| -rw-r--r-- | assets/cgit.css | 1 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -rw-r--r-- | source/ui-tag.c | 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -rwxr-xr-x | tests/t0113-tag.sh | 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3 files changed, 93 insertions, 32 deletions
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("<tr><th>tag</th><td colspan='2'>"); + html_txt(revname); + if (oid) + htmlf(" (<span class='oid'>%s</span>)", oid_to_hex(oid)); + html("</td></tr>\n"); +} + static void print_object_row(struct object *obj) { - html("<tr><th>tagged object</th><td class='oid'>"); + html("<tr><th>object</th><td colspan='2' class='oid'>"); cgit_object_link(obj); html("</td></tr>\n"); } static void print_download_row(const char *revname) { - html("<tr><th>download</th><td class='oid'>"); + html("<tr><th>download</th><td colspan='2' class='oid'>"); cgit_print_snapshot_links(ctx.repo, revname, "<br>"); html("</td></tr>\n"); } +static void print_tagger_row(struct taginfo *info) +{ + html("<tr><th>tagger</th><td>"); + // 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("</td><td class='right'>"); + if (info->tagger_date > 0) { + html("<time datetime='"); + html_attr(show_date(info->tagger_date, info->tagger_tz, cgit_date_mode(DATE_ISO8601_STRICT))); + html("'>"); + html_txt(show_date(info->tagger_date, info->tagger_tz, cgit_date_mode(DATE_ISO8601))); + html("</time>"); + } + html("</td></tr>\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("</div>"); if (newline) { + body = newline + 1; + while (*body == '\n') + body++; html("<div class='commit-msg'>"); - html_txt(newline + 1); + html_txt(body); html("</div>"); } } @@ -68,29 +106,9 @@ static void print_annotated_tag(const char *revname, const struct object_id *oid cgit_print_layout_start(); html("<table class='commit-info'>\n"); - html("<tr><th>tag name</th><td>"); - html_txt(revname); - htmlf(" (<span class='oid'>%s</span>)</td></tr>\n", oid_to_hex(oid)); - if (info->tagger_date > 0) { - html("<tr><th>tag date</th><td><time datetime='"); - html_attr(show_date(info->tagger_date, info->tagger_tz, cgit_date_mode(DATE_ISO8601_STRICT))); - html("'>"); - html_txt(show_date(info->tagger_date, info->tagger_tz, cgit_date_mode(DATE_ISO8601))); - html("</time></td></tr>\n"); - } - if (info->tagger) { - html("<tr><th>tagged by</th><td>"); - // 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("</td></tr>\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("<table class='commit-info'>\n"); - html("<tr><th>tag name</th><td>"); - html_txt(revname); - html("</td></tr>\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 "<tr><th>tagger</th><td>C O Mitter <committer@example.com></td><td class=.right.><time datetime=" tmp +' + +test_expect_success 'find the tag, object and download rows' ' + grep "<tr><th>tag</th><td colspan=.2.>v1.0 (<span class=.oid.>[0-9a-f]*</span>)</td></tr>" tmp && + grep "<tr><th>object</th><td colspan=.2. class=.oid.><a" tmp && + grep "<tr><th>download</th><td colspan=.2. class=.oid.>" tmp +' + +test_expect_success 'the message follows with no blank line before the body' ' + tr -d "\n" <tmp >flat && + grep "<div class=.commit-subject.>Annotated tag</div><div class=.commit-msg.>Release notes overtwo lines.</div>" flat +' + +test_expect_success 'a lightweight tag gets the shorter table' ' + cgit_url "foo/tag/&h=light" >tmp && + grep "<tr><th>tag</th><td colspan=.2.>light</td></tr>" tmp && + grep "<tr><th>object</th><td colspan=.2. class=.oid.><a" tmp && + ! grep "<th>tagger</th>" tmp +' + +test_done |
