diff options
Diffstat (limited to '')
| -rw-r--r-- | source/ui-refs.c | 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -rw-r--r-- | source/ui-shared.c | 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -rw-r--r-- | source/ui-shared.h | 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -rw-r--r-- | source/ui-tag.c | 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -rwxr-xr-x | tests/t0113-tag.sh | 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
5 files changed, 55 insertions, 47 deletions
diff --git a/source/ui-refs.c b/source/ui-refs.c index 42a3cfb..c375137 100644 --- a/source/ui-refs.c +++ b/source/ui-refs.c @@ -108,7 +108,7 @@ static int print_branch(struct refinfo *ref) } else { // The object link sits in the message column, and the empty // tail cells keep the row as wide as the header. - cgit_object_link(ref->object); + cgit_object_link(ref->object, 0); html("</td><td class='col-author'></td><td colspan='2'>"); } html("</td></tr>\n"); @@ -153,7 +153,7 @@ static int print_tag(struct refinfo *ref) if (ctx.repo->snapshots && (obj->type == OBJ_COMMIT)) cgit_print_snapshot_links(ctx.repo, name, " "); else - cgit_object_link(obj); + cgit_object_link(obj, 0); html("</td><td class='col-author'>"); if (info) { if (info->tagger) { diff --git a/source/ui-shared.c b/source/ui-shared.c index 2f0843c..bb786a6 100644 --- a/source/ui-shared.c +++ b/source/ui-shared.c @@ -1020,16 +1020,21 @@ void cgit_stats_link(const char *name, const char *title, const char *class, reporevlink("stats", name, title, class, head, NULL, path); } -void cgit_object_link(struct object *obj) +void cgit_object_link(struct object *obj, int full) { const char *page; char *shortrev, *fullrev, *name; fullrev = oid_to_hex(&obj->oid); - shortrev = xstrdup(fullrev); - shortrev[SHORT_HASH_LEN] = '\0'; + if (full) { + name = cgit_fmt("%s %s", type_name(obj->type), fullrev); + } else { + shortrev = xstrdup(fullrev); + shortrev[SHORT_HASH_LEN] = '\0'; + name = cgit_fmt("%s %s...", type_name(obj->type), shortrev); + } if (obj->type == OBJ_COMMIT) { - cgit_commit_link(cgit_fmt("commit %s...", shortrev), NULL, NULL, ctx.qry.head, fullrev, NULL); + cgit_commit_link(name, NULL, NULL, ctx.qry.head, fullrev, NULL); return; } else if (obj->type == OBJ_TREE) page = "tree"; @@ -1037,7 +1042,6 @@ void cgit_object_link(struct object *obj) page = "tag"; else page = "blob"; - name = cgit_fmt("%s %s...", type_name(obj->type), shortrev); reporevlink(page, name, NULL, NULL, ctx.qry.head, fullrev, NULL); } diff --git a/source/ui-shared.h b/source/ui-shared.h index 8a1a2b8..e2d2db9 100644 --- a/source/ui-shared.h +++ b/source/ui-shared.h @@ -60,7 +60,8 @@ extern void cgit_diff_link(const char *name, const char *title, const char *clas const char *head, const char *new_rev, const char *old_rev, const char *path); extern void cgit_stats_link(const char *name, const char *title, const char *class, const char *head, const char *path); -extern void cgit_object_link(struct object *obj); +// Names the object by type and id, abbreviated unless full is set. +extern void cgit_object_link(struct object *obj, int full); extern void cgit_submodule_link(const char *class, char *path, const char *rev); diff --git a/source/ui-tag.c b/source/ui-tag.c index 02fbfc7..56862bb 100644 --- a/source/ui-tag.c +++ b/source/ui-tag.c @@ -17,34 +17,27 @@ #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) +static void print_name_row(const char *revname, const struct object_id *oid) { - html("<tr><th>tag</th><td colspan='2'>"); + html("<tr><th>tag name</th><td>"); 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>object</th><td colspan='2' class='oid'>"); - cgit_object_link(obj); - html("</td></tr>\n"); -} - -static void print_download_row(const char *revname) +static void print_date_row(struct taginfo *info) { - html("<tr><th>download</th><td colspan='2' class='oid'>"); - cgit_print_snapshot_links(ctx.repo, revname, "<br>"); - html("</td></tr>\n"); + 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"); } static void print_tagger_row(struct taginfo *info) { - html("<tr><th>tagger</th><td>"); + 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"); @@ -54,14 +47,20 @@ static void print_tagger_row(struct taginfo *info) 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"); +} + +static void print_object_row(struct object *obj) +{ + html("<tr><th>tagged object</th><td class='oid'>"); + cgit_object_link(obj, 1); + html("</td></tr>\n"); +} + +static void print_download_row(const char *revname) +{ + html("<tr><th>download</th><td class='oid'>"); + cgit_print_snapshot_links(ctx.repo, revname, "<br>"); html("</td></tr>\n"); } @@ -106,9 +105,11 @@ static void print_annotated_tag(const char *revname, const struct object_id *oid cgit_print_layout_start(); html("<table class='commit-info'>\n"); + print_name_row(revname, oid); + if (info->tagger_date > 0) + print_date_row(info); 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); @@ -122,7 +123,7 @@ static void print_lightweight_tag(const char *revname, struct object *obj) { cgit_print_layout_start(); html("<table class='commit-info'>\n"); - print_tag_row(revname, NULL); + print_name_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 index 12ad1b4..90763bd 100755 --- a/tests/t0113-tag.sh +++ b/tests/t0113-tag.sh @@ -1,9 +1,9 @@ #!/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. +# The tag page. An annotated tag gets a table of its name, date, tagger, the +# object it points at under its full id, and the downloads, 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 @@ -21,14 +21,16 @@ two lines." v1.0 && 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 name, date and tagger rows' ' + grep "<tr><th>tag name</th><td>v1.0 (<span class=.oid.>[0-9a-f]*</span>)</td></tr>" tmp && + grep "<tr><th>tag date</th><td><time datetime=" tmp && + grep "<tr><th>tagged by</th><td>C O Mitter <committer@example.com></td></tr>" 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 object row names the full commit id' ' + commit=$(git -C repos/foo rev-parse v1.0^{commit}) && + grep "<tr><th>tagged object</th><td class=.oid.><a href=./foo/commit/?h=v1.0&id=$commit.>commit $commit</a></td></tr>" tmp && + grep "<tr><th>download</th><td class=.oid.>" tmp ' test_expect_success 'the message follows with no blank line before the body' ' @@ -38,9 +40,9 @@ test_expect_success 'the message follows with no blank line before the body' ' 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 + grep "<tr><th>tag name</th><td>light</td></tr>" tmp && + grep "<tr><th>tagged object</th><td class=.oid.><a" tmp && + ! grep "<th>tagged by</th>" tmp ' test_done |
