lean4-htt/script/prepare-commit-msg

25 lines
440 B
Bash
Executable file

#!/bin/bash
set -eo pipefail
# exit on existing commit message
[[ -z "$2" ]] || exit 0
diff=$(git diff --staged --stat | head -n -1)
[[ $(echo "$diff" | wc -l) == 1 ]] || exit 0
file=$(echo "$diff" | cut -f 2 -d' ')
file="${file%.*}"
case $file in
tests/*)
type=test
;;
script/*)
type=chore
;;
*)
type=feat
;;
esac
orig=$(cat "$1")
echo "$type($file):" > $1
echo "$orig" >> $1