-
Notifications
You must be signed in to change notification settings - Fork 20
/
step-048.sh
32 lines (25 loc) · 1000 Bytes
/
step-048.sh
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
#!/bin/sh
# Test:
# Direct template execution: do not run any hooks in any repos
mkdir -p ~/.githooks/release && cp /var/lib/githooks/*.sh ~/.githooks/release || exit 1
git config --global githooks.disable true || exit 1
mkdir -p /tmp/test48 && cd /tmp/test48 || exit 1
git init || exit 1
mkdir -p .githooks/pre-commit &&
echo 'echo "Accepted hook" > /tmp/test48.out' >.githooks/pre-commit/test &&
HOOK_NAME=pre-commit HOOK_FOLDER=$(pwd)/.git/hooks \
ACCEPT_CHANGES=Y \
sh ~/.githooks/release/base-template-wrapper.sh
if [ -f /tmp/test48.out ]; then
echo "! Hook was unexpectedly run"
exit 1
fi
git config --global --unset githooks.disable || exit 1
echo 'echo "Changed hook" > /tmp/test48.out' >.githooks/pre-commit/test &&
HOOK_NAME=pre-commit HOOK_FOLDER=$(pwd)/.git/hooks \
ACCEPT_CHANGES=Y \
sh ~/.githooks/release/base-template-wrapper.sh
if ! grep -q "Changed hook" /tmp/test48.out; then
echo "! Changed hook was not run"
exit 1
fi