validate-commit-msg用于检查Node项目的Commit message是否符合格式
它需要将js文件拷贝到代码库,然后将脚本加入Git的hook.
下面是在package.json里面使用ghooks,将这个脚本加为commit-msg
"config": {
"ghooks": {
"commit-msg": "./validate-commit-msg.js"
}
}
然后在每次执行git commit时,脚本会自动检查Commit message是否合格,如果不合格,则会报错
$ git add -A
$ git commit -m "edit markdown"
INVALID COMMIT MSG: does not match "<type>(<scope>): <subject>" ! was: edit markdown