Open
Description
- https://gist.github.com/pgilad/5d7e4db725a906bd7aa7
- https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks
- http://stackoverflow.com/questions/29568414/git-hook-commit-msg-to-ensure-the-commit-message-contains-a-string-that-conforms
- 必须有自己的名字
- 必须有 issue number(没需求就不做卡)
- 必须有 前缀(feature/refactor/fix/chore/style/docs)
- 前缀后面必须有冒号
- 冒号后面必须有一个空格
- 空格后面必须小写开头
- 必须不多于70个字符
- 详细的错误信息
后两个太难,暂时放弃了。
#!/bin/sh
commit_regex="\[Linesh\]\[#\d*\]\s\(Chore\|Feature\|Fix\|Docs\|Style\|Refactor\|Test\):\s[a-z]"
error_msg="Aborting commit, please double check your commit message."
if ! echo "$1" | grep -iqE "$commit_regex" ;
then
echo "$error_msg" >&2
exit 1
fi
Metadata
Metadata
Assignees
Labels
No labels