dotfiles/.config/git/template/hooks/prepare-commit-msg

14 lines
355 B
Plaintext
Raw Normal View History

2022-03-18 14:34:27 +01:00
#!/bin/sh
COMMIT_MSG_FILE="${1}"
COMMIT_SOURCE="${2}"
SHA1="${3}"
# Only run on new commits.
if [ -z "${SHA1}" ] && [ -z "${COMMIT_SOURCE}" ]; then
# Show last 4 commit messages.
echo '' >> "${COMMIT_MSG_FILE}"
echo '# Previous commits:' >> "${COMMIT_MSG_FILE}"
git log --pretty=format:'# %h %s' | head -n 4 >> "${COMMIT_MSG_FILE}"
fi