@@ -18,12 +18,13 @@ CURRENT_STEP=0
1818progress " $CURRENT_STEP " " $TOTAL_STEPS "
1919
2020if ! 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 ."
2222fi
2323
2424workspace=$( git rev-parse --show-toplevel)
2525if [ ! -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."
2728fi
2829
2930# 2. Check GitHub account
8889(( CURRENT_STEP++ ))
8990progress " $CURRENT_STEP " " $TOTAL_STEPS "
9091
91- mkdir -p .git/hooks
92+ HOOKS_DIR=" .git/hooks"
93+ mkdir -p " $HOOKS_DIR " || exit 1
9294
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)
9597
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
104102
105103touch .git/hooks/applied || exit 1
106104
0 commit comments