From a5b987a7399089de30f2223402d70d528e3b845c Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Fri, 16 Oct 2026 18:24:58 -1000 Subject: Check every markup hook the README names The README promised that t0005 checked them all, while fourteen went unchecked, and three of its claims were too broad. A date shown in full carries no age hooks, line anchors follow enable-tree-linenumbers and cgit.css also styles html.cgit-standalone. --- README.txt | 19 ++++++++------ tests/t0005-markup.sh | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 8 deletions(-) diff --git a/README.txt b/README.txt index 13b0971..37141d3 100644 --- a/README.txt +++ b/README.txt @@ -88,11 +88,14 @@ script added through the css and js options has stable hooks to work with. table.commit-trailers, the diffstat is table.diffstat and each file of a diff is div.file, or tbody.file in the side by side view, with the path in data-path. The blob and blame pages open with div.blob-header. -* Ages are time elements with an age-* class and the timestamp in data-ut. Line - numbers are anchors named n followed by the line. +* Relative ages are time elements with an age-* class and the timestamp in + data-ut, while a date shown in full is a plain time element. Line numbers are + anchors named n followed by the line, while enable-tree-linenumbers is on. * Colours, fonts and metrics are custom properties on div#cgit, so a theme can - redefine those alone. Every rule in cgit.css starts with div#cgit, and a rule - of your own needs the same prefix to win. + redefine those alone. Every rule in cgit.css starts with div#cgit, apart from + the background and margins it sets on html.cgit-standalone, the class of the + document cgit writes when it is not embedded. A rule of your own needs the + div#cgit prefix to win. * The script exposes window.cgit.updateAges and window.cgit.highlightLines for a page that changes the rows or the lines after load. @@ -192,10 +195,10 @@ feed rather than a page and accepts h, path and all. The clone endpoints under info and objects implement the dumb HTTP protocol and are only present when http clone is enabled. -A url fragment can address lines inside a file. The tree and blame pages give -every line an anchor named n followed by its number, so #n17 jumps to line 17 -and highlights it, and a range written #n17-n24 highlights the whole run and -scrolls it into view. +A url fragment can address lines inside a file. While enable-tree-linenumbers is +on, as it is by default, the tree and blame pages give every line an anchor +named n followed by its number, so #n17 jumps to line 17 and highlights it, and +a range written #n17-n24 highlights the whole run and scrolls it into view. Some worked examples, in the url= form. diff --git a/tests/t0005-markup.sh b/tests/t0005-markup.sh index 2a8d572..bbf78b1 100755 --- a/tests/t0005-markup.sh +++ b/tests/t0005-markup.sh @@ -96,4 +96,77 @@ test_expect_success 'the stylesheet and the script name only the current hooks' grep "window.cgit.highlightLines" "$TEST_OUTPUT_DIRECTORY/../assets/cgit.js" ' +# The rest of the hooks need a tag, a symlink, a submodule, a trailer, clone +# urls and a second page of repositories, so they get a commit and a config +# of their own after the checks above have read the first ones. +test_expect_success 'set up the remaining kinds of entry' ' + ( + cd repos/hooks && + git tag -a -m "first release" v1 && + test_ln_s_add file-1 link && + git update-index --add --cacheinfo "160000,$(git rev-parse HEAD),sub" && + git commit -m "more kinds of entry" -m "Fixes: $(git rev-parse --short HEAD)" + ) && + { + echo "virtual-root=/" && + echo "cache-size=0" && + echo "enable-commit-trailers=1" && + echo "max-repo-count=1" && + echo "clone-url=https://example.com/clone.git" && + echo "repo.url=hooks" && + echo "repo.path=$PWD/repos/hooks/.git" && + echo "repo.url=again" && + echo "repo.path=$PWD/repos/hooks/.git" + } >morerc +' + +more() { CGIT_CONFIG="$PWD/morerc" QUERY_STRING="url=$1" cgit; } + +test_expect_success 'the refs, summary and tree name every section and row' ' + more "hooks/refs/" >tmp && + grep "" tmp && + grep "" tmp && + grep "" tmp && + more "hooks/" >tmp && + grep "" tmp && + more "hooks/tree/" >tmp && + grep "" tmp && + grep "" tmp && + grep "" tmp +' + +test_expect_success 'the commit page has its trailer table and diffstat' ' + more "hooks/commit/" >tmp && + grep "
" tmp && + grep "
" tmp +' + +test_expect_success 'the breadcrumb, the pager and the ages carry their hooks' ' + more "hooks/tree/dir/" >tmp && + grep "