From d187a24834163e24741302fad5077c9e2dade9f2 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 15:28:30 -1000 Subject: Push to each hook installed as post-receive No hook ran the way git runs it, so the shebang, the executable bit, GIT_DIR, the refs on stdin and the remote: lines a pusher sees were all untested. --- tests/t0507-hooks.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'tests') diff --git a/tests/t0507-hooks.sh b/tests/t0507-hooks.sh index 0a869f9..6be6d06 100755 --- a/tests/t0507-hooks.sh +++ b/tests/t0507-hooks.sh @@ -443,4 +443,39 @@ do ' done +# Installed, a hook runs by its shebang with GIT_DIR set and the pushed refs +# on stdin, and whatever it prints reaches the pusher behind "remote:". +test_expect_success 'the age hook works installed in a repository pushed to' ' + git init -q --bare pushed-age.git && + cp "$HOOK_DIRECTORY/post-receive.cgit-age" pushed-age.git/hooks/post-receive && + git -C work push ../pushed-age.git main 2>push-err && + test_grep "main -> main" push-err && + test_grep ! "^remote:" push-err && + test_cmp expect pushed-age.git/info/web/last-modified +' + +test_expect_success 'the cache hook works installed in a repository pushed to' ' + fresh_slots && + cp cache-hook scan/a.git/hooks/post-receive && + chmod +x scan/a.git/hooks/post-receive && + test_when_finished "rm -f scan/a.git/hooks/post-receive" && + test_commit -C pusher pushed && + git -C pusher push ../scan/a.git HEAD:refs/heads/main 2>push-err && + test_grep "HEAD -> main" push-err && + test_grep ! "^remote:" push-err && + cached_requests slots >left && + test_grep "|/b.git/log/" left && + test_grep ! "a.git" left +' + +test_expect_success 'the commit-graph hook works installed in a repository pushed to' ' + git init -q --bare pushed-graph.git && + cp "$HOOK_DIRECTORY/post-receive.commit-graph" pushed-graph.git/hooks/post-receive && + git -C work push ../pushed-graph.git main 2>push-err && + test_grep "main -> main" push-err && + test_grep ! "^remote:" push-err && + test_path_is_file pushed-graph.git/objects/info/commit-graphs/commit-graph-chain && + git -C pushed-graph.git commit-graph verify +' + test_done -- cgit 2.12.1