mirror of
https://github.com/git/git
synced 2024-10-30 14:03:28 +00:00
bef805b7d8
Change tests that used a "mkdir -p .git/hooks && write_script" pattern to use the new "test_hook" helper instead. The new helper does not create the .git/hooks directory, rather we assume that the default template will do so for us. An upcoming series[1] will extend "test_hook" to operate in a "--template=" mode, but for now assuming that we have a .git/hooks already is a safe assumption. If that assumption becomes false in the future we'll only need to change 'test_hook", instead of all of these callsites. 1. https://lore.kernel.org/git/cover-00.13-00000000000-20211212T201308Z-avarab@gmail.com/ Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
44 lines
1.1 KiB
Bash
Executable file
44 lines
1.1 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
test_description='Test the core.hooksPath configuration variable'
|
|
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success 'set up a pre-commit hook in core.hooksPath' '
|
|
>actual &&
|
|
mkdir -p .git/custom-hooks &&
|
|
write_script .git/custom-hooks/pre-commit <<-\EOF &&
|
|
echo CUSTOM >>actual
|
|
EOF
|
|
test_hook --setup pre-commit <<-\EOF
|
|
echo NORMAL >>actual
|
|
EOF
|
|
'
|
|
|
|
test_expect_success 'Check that various forms of specifying core.hooksPath work' '
|
|
test_commit no_custom_hook &&
|
|
git config core.hooksPath .git/custom-hooks &&
|
|
test_commit have_custom_hook &&
|
|
git config core.hooksPath .git/custom-hooks/ &&
|
|
test_commit have_custom_hook_trailing_slash &&
|
|
git config core.hooksPath "$PWD/.git/custom-hooks" &&
|
|
test_commit have_custom_hook_abs_path &&
|
|
git config core.hooksPath "$PWD/.git/custom-hooks/" &&
|
|
test_commit have_custom_hook_abs_path_trailing_slash &&
|
|
cat >expect <<-\EOF &&
|
|
NORMAL
|
|
CUSTOM
|
|
CUSTOM
|
|
CUSTOM
|
|
CUSTOM
|
|
EOF
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_expect_success 'git rev-parse --git-path hooks' '
|
|
git config core.hooksPath .git/custom-hooks &&
|
|
git rev-parse --git-path hooks/abc >actual &&
|
|
test .git/custom-hooks/abc = "$(cat actual)"
|
|
'
|
|
|
|
test_done
|