From a3bb7c69c0295cb2fc7909559456e798b222fccd Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 31 Oct 2026 14:56:59 -0700 Subject: Add the shared config writers and cgit_rc The helpers are named by kind. cgitrc_repo and cgitrc_copy write the config file named first, and cgit_url, cgit_query and cgit_rc run cgit, each named after what it is handed first. A repository copies its defaults from the globals read before its repo.url, so cgitrc_repo places every setting itself, and a global can no longer land where it silently stops applying. The t00xx and t01xx files move to them here. --- tests/t0112-stats.sh | 50 +++++++++++++++----------------------------------- 1 file changed, 15 insertions(+), 35 deletions(-) (limited to 'tests/t0112-stats.sh') diff --git a/tests/t0112-stats.sh b/tests/t0112-stats.sh index 3728412..5100793 100755 --- a/tests/t0112-stats.sh +++ b/tests/t0112-stats.sh @@ -28,31 +28,17 @@ test_expect_success 'set up a stats config' ' git commit --allow-empty -m fresh && git commit-graph write --reachable ) && - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "max-stats=year" && - echo "repo.url=stat" && - echo "repo.path=$PWD/repos/pulse/.git" - } >statsrc && - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "max-stats=month" && - echo "repo.url=stat" && - echo "repo.path=$PWD/repos/pulse/.git" - } >statmaxrc + cgitrc_repo statsrc stat max-stats=year "repo.path=$PWD/repos/pulse/.git" && + cgitrc_repo statmaxrc stat max-stats=month "repo.path=$PWD/repos/pulse/.git" ' -statq() { CGIT_CONFIG="$PWD/statsrc" QUERY_STRING="$1" cgit; } - test_expect_success 'stats tab appears when enabled' ' - statq "url=stat/" >tmp && + cgit_rc statsrc "url=stat/" >tmp && grep ">stats" tmp ' test_expect_success 'stats page renders the authors table' ' - statq "url=stat/stats/" >tmp && + cgit_rc statsrc "url=stat/stats/" >tmp && grep "

Commits per author" tmp ' @@ -65,13 +51,13 @@ test_expect_success 'stat options sit above the content' ' ' test_expect_success 'stats below a path stay a normal page' ' - statq "url=stat/stats/file-1" >tmp && + cgit_rc statsrc "url=stat/stats/file-1" >tmp && grep "Status: 200" tmp && grep "

Commits per author" tmp ' test_expect_success 'max-stats=year offers all four periods' ' - statq "url=stat/stats/" >tmp && + cgit_rc statsrc "url=stat/stats/" >tmp && grep "