1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
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_expect_success 'the age hook writes the newest branch date' '
test_create_repo work &&
test_commit -C work first &&
git init -q --bare plain.git &&
git -C work push -q ../plain.git HEAD:refs/heads/main &&
(cd plain.git && sh "$HOOK_DIRECTORY/post-receive.cgit-age") &&
git -C plain.git for-each-ref --format="%(committerdate:iso8601)" refs/heads/main >expect &&
test_cmp expect plain.git/info/web/last-modified
'
test_expect_success SANITY 'the age hook keeps a shared directory group writable' '
git init -q --bare --shared=group shared.git &&
git -C work push -q ../shared.git HEAD:refs/heads/main &&
(cd shared.git && umask 022 && sh "$HOOK_DIRECTORY/post-receive.cgit-age") &&
ls -ld shared.git/info/web >mode &&
grep "^drwxrw[xs]" mode
'
test_done
|