From 8a7aa400143f3e95b3ecd18f19e21b526d6a419d Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 31 Oct 2026 19:47:34 -1000 Subject: Read the description file without repo.desc Only a scanned repository fell back to its description file, so one listed in cgitrc without repo.desc showed "[no description]" however its file read. repo.desc may follow repo.path, so the file is read where a page shows the description, which also spares every other request the reads. --- tests/setup.sh | 3 ++- tests/t0101-index.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/setup.sh b/tests/setup.sh index 92451b7..421e043 100755 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -130,7 +130,8 @@ clone-url=git://example.org/\$CGIT_REPO_URL.git repo.url=foo repo.path=$PWD/repos/foo/.git -# No repo.desc here, so the [no description] default gets exercised. +# No repo.desc here, and the description file holds git's placeholder, so +# the [no description] default gets exercised. repo.url=bar repo.path=$PWD/repos/bar/.git diff --git a/tests/t0101-index.sh b/tests/t0101-index.sh index 9b02a18..0953b8d 100755 --- a/tests/t0101-index.sh +++ b/tests/t0101-index.sh @@ -93,4 +93,30 @@ test_expect_success 'a scan lists repositories in path order' ' test_cmp expect order ' +# A repository listed without repo.desc shows the first line of its own +# description file, as a scanned one does. A repo.desc after the repo.path +# still wins, and git's placeholder still reads as no description. +test_expect_success 'a repository without repo.desc reads its description file' ' + mkrepo repos/described 1 && + printf "told by the file\nsecond line\n" >repos/described/.git/description && + { + echo "virtual-root=/" && + echo "cache-size=0" && + echo "repo.url=described" && + echo "repo.path=$PWD/repos/described/.git" && + echo "repo.url=overridden" && + echo "repo.path=$PWD/repos/described/.git" && + echo "repo.desc=from cgitrc" && + echo "repo.url=placeholder" && + echo "repo.path=$PWD/repos/foo/.git" + } >describedrc && + cgit_rc describedrc "url=" >tmp && + grep "href=./described/.>told by the file" tmp && + grep "href=./overridden/.>from cgitrc" tmp && + grep "href=./placeholder/.>\[no description\]" tmp && + ! grep "second line" tmp && + cgit_rc describedrc "url=described/" >tmp && + grep "" tmp +' + test_done -- cgit 2.12.1