From 2a6e0136d07febedabd7d4e47379dd425b3013f9 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 14:45:11 -1000 Subject: Check what the age hook leaves behind A repository with no branches is meant to keep the date cgit already had, and the hook writes through a temporary file that must not be left beside the real one. Neither was checked. --- tests/t0507-hooks.sh | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/t0507-hooks.sh b/tests/t0507-hooks.sh index 4d5a9e3..c95c8a3 100755 --- a/tests/t0507-hooks.sh +++ b/tests/t0507-hooks.sh @@ -160,7 +160,9 @@ test_expect_success 'set up a repository whose dates disagree' ' ) && git init -q --bare plain.git && git -C work push -q ../plain.git main old loose release && - echo "2021-02-03 04:05:06 +0000" >expect + echo "2021-02-03 04:05:06 +0000" >expect && + echo last-modified >expect-entries && + echo kept >kept ' for shell in $shells @@ -169,17 +171,30 @@ do rm -f plain.git/info/web/last-modified && (cd plain.git && $shell "$HOOK_DIRECTORY/post-receive.cgit-age" 2>../err) && test_must_be_empty err && - test_cmp expect plain.git/info/web/last-modified + test_cmp expect plain.git/info/web/last-modified && + ls plain.git/info/web >entries && + test_cmp expect-entries entries ' test_expect_success SANITY "the age hook shows a pusher no error under $shell" ' - echo kept >kept && cp kept plain.git/info/web/last-modified && test_when_finished "chmod 755 plain.git/info/web" && chmod 555 plain.git/info/web && (cd plain.git && $shell "$HOOK_DIRECTORY/post-receive.cgit-age" 2>../err) && test_must_be_empty err && - test_cmp kept plain.git/info/web/last-modified + test_cmp kept plain.git/info/web/last-modified && + ls plain.git/info/web >entries && + test_cmp expect-entries entries + ' + + test_expect_success "the age hook leaves a repository with no branches as it was under $shell" ' + git init -q --bare tags-$shell.git && + git -C work push -q ../tags-$shell.git release && + mkdir -p tags-$shell.git/info/web && + echo kept >tags-$shell.git/info/web/last-modified && + (cd tags-$shell.git && $shell "$HOOK_DIRECTORY/post-receive.cgit-age" 2>../err) && + test_must_be_empty err && + test_cmp kept tags-$shell.git/info/web/last-modified ' test_expect_success SANITY "the age hook shows no error when it cannot make its directory under $shell" ' -- cgit 2.12.1