t/t7503-pre-commit-hook.sh: Add GIT_PREFIX tests
Ensure that the pre-commit hook has access to GIT_PREFIX. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
f9ad901fd3
commit
c35ec8c901
@ -84,5 +84,38 @@ test_expect_success POSIXPERM '--no-verify with non-executable hook' '
|
||||
git commit --no-verify -m "more content"
|
||||
|
||||
'
|
||||
chmod +x "$HOOK"
|
||||
|
||||
# a hook that checks $GIT_PREFIX and succeeds inside the
|
||||
# success/ subdirectory only
|
||||
cat > "$HOOK" <<EOF
|
||||
#!/bin/sh
|
||||
test \$GIT_PREFIX = success/
|
||||
EOF
|
||||
|
||||
test_expect_success 'with hook requiring GIT_PREFIX' '
|
||||
|
||||
echo "more content" >> file &&
|
||||
git add file &&
|
||||
mkdir success &&
|
||||
(
|
||||
cd success &&
|
||||
git commit -m "hook requires GIT_PREFIX = success/"
|
||||
) &&
|
||||
rmdir success
|
||||
'
|
||||
|
||||
test_expect_success 'with failing hook requiring GIT_PREFIX' '
|
||||
|
||||
echo "more content" >> file &&
|
||||
git add file &&
|
||||
mkdir fail &&
|
||||
(
|
||||
cd fail &&
|
||||
test_must_fail git commit -m "hook must fail"
|
||||
) &&
|
||||
rmdir fail &&
|
||||
git checkout -- file
|
||||
'
|
||||
|
||||
test_done
|
||||
|
Loading…
Reference in New Issue
Block a user