commit-msg
1 #!/usr/bin/env bash 2 # Sanitize file first, by removing leading lines that are empty or start with a hash, 3 # as `convco` currently does not do it automatically (but git will) 4 # TODO: next release of convco should be able to do it automatically 5 MESSAGE="$( 6 while read -r line ; do 7 # skip any initial comments (possibly from previous run) 8 if [ -z "${body_detected:-}" ] && { [[ "$line" =~ ^#.*$ ]] || [ "$line" == "" ]; }; then 9 continue 10 fi 11 body_detected="true" 12 13 echo "$line" 14 done < "$1" 15 )" 16 17 # convco fails on fixup!, so remove fixup! prefix 18 MESSAGE="${MESSAGE#fixup! }" 19 if ! convco check --from-stdin <<<"$MESSAGE" ; then 20 >&2 echo "Please follow conventional commits(https://www.conventionalcommits.org)" 21 >&2 echo "Use git commit <args> to fix your commit" 22 exit 1 23 fi