Created
June 30, 2017 10:04
-
-
Save Vadimhtml/477d6b169a85d3fee0028f0c0d9644df to your computer and use it in GitHub Desktop.
Git хук на проверку «refs #» в имени коммита
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment