From b03fb1189860feebedc6d1b57a19855a267647bf Mon Sep 17 00:00:00 2001 From: Alban Tamisier Date: Tue, 3 Sep 2019 19:13:34 +0200 Subject: [PATCH] Add spelling check --- hook.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/hook.sh b/hook.sh index f29b7c5..019cd08 100755 --- a/hook.sh +++ b/hook.sh @@ -140,6 +140,22 @@ validate_commit_message() { # if the commit subject starts with 'fixup! ' there's nothing to validate, we can return here [[ $COMMIT_SUBJECT == 'fixup! '* ]] && return; + + # 0. Check spelling + # ------------------------------------------------------------------------------ + ASPELL=$(which aspell) + if [ $? -ne 0 ]; then + echo "Aspell not installed - unable to check spelling" + else + for i in "${!v}"; do + LINE_NUMBER=$((i+1)) + MISSPELLED_WORDS=`echo "$COMMIT_MSG_LINES[LINE_NUMBER]" | $ASPELL --list` + if [ -n "$MISSPELLED_WORDS" ]; then + add_warning LINE_NUMBER "Possible misspelled word(s): $MISSPELLED_WORDS" + fi + done + fi + # 1. Separate subject from body with a blank line # ------------------------------------------------------------------------------