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/t0102-summary.sh | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'tests/t0102-summary.sh') diff --git a/tests/t0102-summary.sh b/tests/t0102-summary.sh index 9b47cc2..9e0e14c 100755 --- a/tests/t0102-summary.sh +++ b/tests/t0102-summary.sh @@ -33,14 +33,8 @@ test_expect_success 'a git clone url row falls back to the page url' ' ' test_expect_success 'an scp clone url row links to the http url' ' - { - echo "virtual-root=/" && - echo "cache-size=0" && - echo "repo.url=foo" && - echo "repo.path=$PWD/repos/foo/.git" && - echo "repo.clone-url=git@example.org:foo https://example.org/foo" - } >clonerc && - CGIT_CONFIG="$PWD/clonerc" QUERY_STRING="url=foo" cgit >tmp && + cgitrc_repo clonerc foo "repo.clone-url=git@example.org:foo https://example.org/foo" && + cgit_rc clonerc "url=foo" >tmp && grep "title=.foo Git repository. href=.https://example.org/foo.>git@example.org:foo" tmp && grep "vcs-git. href=.https://example.org/foo." tmp && ! grep "vcs-git. href=.git@" tmp @@ -64,13 +58,13 @@ test_expect_success 'an empty clone url draws no clone heading' ' echo "repo.url=cloned" && echo "repo.path=$PWD/repos/empty.git" } >emptyrc && - CGIT_CONFIG="$PWD/emptyrc" QUERY_STRING="url=foo" cgit >tmp && + cgit_rc emptyrc "url=foo" >tmp && grep "commit 1" tmp && ! grep "Clone" tmp && - CGIT_CONFIG="$PWD/emptyrc" QUERY_STRING="url=empty" cgit >tmp && + cgit_rc emptyrc "url=empty" >tmp && grep "Repository seems to be empty" tmp && ! grep "Clone" tmp && - CGIT_CONFIG="$PWD/emptyrc" QUERY_STRING="url=cloned" cgit >tmp && + cgit_rc emptyrc "url=cloned" >tmp && grep "Clone" tmp && grep "https://example.org/cloned" tmp ' @@ -98,7 +92,7 @@ row_widths() { # Fails unless every row of the list table at the url is as many columns wide # as the second argument says. A third names a config other than colsrc. test_widths() { - CGIT_CONFIG="$PWD/${3:-colsrc}" QUERY_STRING="url=$1" cgit >tmp && + cgit_rc "${3:-colsrc}" "url=$1" >tmp && row_widths tmp | sort -u >actual && echo "$2" >expect && test_cmp expect actual @@ -132,7 +126,7 @@ test_expect_success 'set up a repo cut short in every section' ' echo "repo.enable-log-filecount=1" && echo "repo.enable-log-linecount=1" } >colsrc && - CGIT_CONFIG="$PWD/colsrc" QUERY_STRING="url=none" cgit >tmp && + cgit_rc colsrc "url=none" >tmp && grep "" tmp && grep "" tmp && test $(grep -c ">\[...\]" tmp) = 3 -- cgit