@@ -18,12 +18,13 @@ CURRENT_STEP=0
18
18
progress " $CURRENT_STEP " " $TOTAL_STEPS "
19
19
20
20
if ! test -d .git; then
21
- throw " Execute scripts/install- git-hooks in the top-level directory ."
21
+ throw " Ensure the git repository is cloned correctly ."
22
22
fi
23
23
24
24
workspace=$( git rev-parse --show-toplevel)
25
25
if [ ! -d " $workspace " ]; then
26
- throw " The workspace path '$workspace ' contains non-ASCII characters."
26
+ throw " Unable to determine the repository's top-level directory.\n\
27
+ This directory $workspace does not appear to be a valid Git repository."
27
28
fi
28
29
29
30
# 2. Check GitHub account
88
89
(( CURRENT_STEP++ ))
89
90
progress " $CURRENT_STEP " " $TOTAL_STEPS "
90
91
91
- mkdir -p .git/hooks
92
+ HOOKS_DIR=" .git/hooks"
93
+ mkdir -p " $HOOKS_DIR " || exit 1
92
94
93
- ln -sf ../../scripts/pre-commit. hook .git/hooks/pre-commit || exit 1
94
- chmod +x .git/hooks/ pre-commit
95
+ # List of hook names.
96
+ HOOKS=(pre-commit commit-msg pre-push prepare- commit-msg)
95
97
96
- ln -sf ../../scripts/commit-msg.hook .git/hooks/commit-msg || exit 1
97
- chmod +x .git/hooks/commit-msg
98
-
99
- ln -sf ../../scripts/pre-push.hook .git/hooks/pre-push || exit 1
100
- chmod +x .git/hooks/pre-push
101
-
102
- ln -sf ../../scripts/prepare-commit-msg.hook .git/hooks/prepare-commit-msg || exit 1
103
- chmod +x .git/hooks/prepare-commit-msg
98
+ for hook in " ${HOOKS[@]} " ; do
99
+ ln -sf " ../../scripts/${hook} .hook" " $HOOKS_DIR /$hook " || exit 1
100
+ chmod +x " $HOOKS_DIR /$hook "
101
+ done
104
102
105
103
touch .git/hooks/applied || exit 1
106
104
0 commit comments