From 763f7866ede8c39288563666c927364c4a4c9c39 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 17:13:19 -1000 Subject: Report a max-stats value that names no period A value cgit does not know as a period turns the statistics page off, so a typo such as "decade" read the same as leaving stats off on purpose. The empty value stays quiet because a cached repolist writes it for a repository that turned stats off. --- tests/t0205-config.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'tests') diff --git a/tests/t0205-config.sh b/tests/t0205-config.sh index 0adb29f..88a271f 100755 --- a/tests/t0205-config.sh +++ b/tests/t0205-config.sh @@ -242,6 +242,33 @@ test_expect_success 'an unknown snapshot format is reported' ' test_must_be_empty err ' +# A max-stats value that names no period turns the statistics page off as if +# it were unset, so it is logged with the file and line it came from. The +# empty value and 0 that turn the page off on purpose stay quiet, and so does +# a period's one letter code. +test_expect_success 'a max-stats that names no period is reported' ' + cgitrc_repo statsrc stats max-stats=decade "repo.path=$PWD/repos/foo/.git" && + cgit_rc statsrc "url=stats/stats/" >tmp 2>err && + test_grep "^Status: 404" tmp && + test_grep -F "Turning statistics off for max-stats=decade in $PWD/statsrc line 3, since it names no period" err && + test_line_count = 1 err && + cgitrc_repo repostatsrc stats max-stats=year "repo.path=$PWD/repos/foo/.git" repo.max-stats=century && + cgit_rc repostatsrc "url=stats/stats/" >tmp 2>err && + test_grep "^Status: 404" tmp && + test_grep -F "Turning statistics off for max-stats=century in $PWD/repostatsrc line 6, since it names no period" err && + test_line_count = 1 err && + cgitrc_repo letterrc stats max-stats=y "repo.path=$PWD/repos/foo/.git" && + cgit_ok letterrc "url=stats/stats/" >tmp && + test_grep "" tmp && + for off in 0 "" + do + cgitrc_repo offrc stats max-stats=year "repo.path=$PWD/repos/foo/.git" "repo.max-stats=$off" && + cgit_rc offrc "url=stats/stats/" >tmp 2>err && + test_grep "^Status: 404" tmp && + test_must_be_empty err || return 1 + done +' + # The error page names the repository alone, so the log gets the path that # would not open, once for the request. test_expect_success 'a repository that will not open is logged with its path' ' -- cgit 2.12.1