From bd29033a1ba325850f6fa29112eee58345fb9da6 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Fri, 16 Oct 2026 06:31:18 -1000 Subject: Keep the cache hook's rm errors from pushers Only the exit status was hidden, so a pusher without write access to the cache root saw a permission error per cached page, against what the hook's own comment promised. --- tests/t0507-hooks.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 tests/t0507-hooks.sh (limited to 'tests/t0507-hooks.sh') diff --git a/tests/t0507-hooks.sh b/tests/t0507-hooks.sh new file mode 100755 index 0000000..ff42468 --- /dev/null +++ b/tests/t0507-hooks.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +# Checks the post-receive hooks under custom/hooks. The cache hook runs from a +# copy pointed at a cache in the trash directory, since the shipped one names +# the system's cache root, and the age hook runs inside bare repositories the +# way git runs it after a push. + +test_description='Check the shipped post-receive hooks' +CGIT_TEST_NO_CREATE_REPOS=YesPlease +. ./setup.sh + +HOOK_DIRECTORY="$TEST_OUTPUT_DIRECTORY/../custom/hooks" + +test_expect_success 'the cache hook clears the slots and keeps the locks' ' + mkdir cache && + echo page >cache/0123abcd && + echo writer >cache/0123abcd.lock && + sed "s|^cache_root=.*|cache_root='\''$PWD/cache'\''|" \ + "$HOOK_DIRECTORY/post-receive.cgit-cache" >cache-hook && + sh cache-hook && + test_path_is_missing cache/0123abcd && + test_path_is_file cache/0123abcd.lock +' + +test_expect_success SANITY 'the cache hook shows a pusher no error' ' + echo page >cache/89abcdef && + test_when_finished "chmod 755 cache" && + chmod 555 cache && + sh cache-hook 2>err && + test_path_is_file cache/89abcdef && + test_must_be_empty err +' + +test_done -- cgit