Created
June 23, 2020 12:59
-
-
Save grigory-rechistov/d7ee6708574e54f8303ca6d703177e59 to your computer and use it in GitHub Desktop.
Check spelling in Git commit hook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add this snippet to the end of your .git/hook/commit-msg script | |
# Check spelling | |
ASPELL=$(which aspell 2> /dev/null) | |
if [ $? -ne 0 ]; then | |
echo "Aspell not installed, unable to check spelling" >&2 | |
else | |
WORDS=$(grep -v "^Change-Id:" "$1"| $ASPELL --mode=email --add-email-quote='#' list | sort -u) | |
if [ -n "$WORDS" ]; then | |
echo -ne "\e[31m" | |
printf "### Possible spelling errors found in commit message: ###\n%s\n" "$WORDS" >&2 | |
echo -ne "\e[0m" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment