Git хук на проверку «refs #» в имени коммита
#!/bin/sh
#
# Хук, который проверяет в имени коммита наличие отсылки
# к задаче Redmine в формате «refs #123456» или слова «merge»
#
# Активируем папку с шаблонами
# git config --global init.templatedir '~/.git-templates'
#
# Создаём директорию для хуков
# mkdir -p ~/.git-templates/hooks
#
# Складываем файл ~/.git-templates/hooks/commit-msg
#
# Делаем запускаемым
# chmod a+x ~/.git-templates/hooks/commit-commit
commit_regex='(refs #[0-9]{6}|merge)'
error_msg="Aborting commit. Your commit message is missing either a Redmine issue ('refs #') or 'merge'"
if ! grep -iqE "$commit_regex" "$1"; then
echo "$error_msg" >&2
exit 1
fi