dotfiles/.config/git/template/hooks/prepare-commit-msg
2022-03-18 15:00:33 +01:00

14 lines
355 B
Bash
Executable File

#!/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