diff options
Diffstat (limited to 'hooks/pre-commit')
| -rwxr-xr-x | hooks/pre-commit | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/hooks/pre-commit b/hooks/pre-commit new file mode 100755 index 0000000..317ed48 --- /dev/null +++ b/hooks/pre-commit @@ -0,0 +1,30 @@ +#!/bin/sh + +# automatically configured by git-annex +git annex pre-commit . + +# check grammar of staged Markdown files +check_grammar() { + # get list of staged Markdown files (added or modified) + staged_files=$(git diff --cached --name-only --diff-filter=AM | grep '\.md$') + + [ -z "$staged_files" ] && return 0 + + printf "Checking grammar of staged files.\n" + language_tool_python --picky $staged_files + + printf "Proceed with commit? (y/n): " + read yn < /dev/tty + + [ "$yn" == "${yn#[Yy]}" ] && return 1 + + return 0 +} + +# run grammar check +check_grammar + +if [ $? -ne 0 ]; then + printf "Aborted.\n" + exit 1 +fi |
