commit-msg
# 1.在项目.git\hooks目录里面编写commit-msg文件
#!/bin/sh
echo "-----------------------------当前操作是: commit-msg-----------------------------"
# 用 `` 可以将命令的输出结果赋值给变量
# 获取当前提交的 commit msg
commit_msg=`cat $1`
# 获取用户 email
email=`git config user.email`
msg_re="^(feat|fix|docs|style|refactor|perf|test|workflow|build|ci|chore|release|workflow)(\(.+\))?: .{1,100}"
if [[ ! $commit_msg =~ $msg_re ]]
then
echo "不合法的 commit 消息提交格式,请使用正确的格式:\
详情请查看 git commit 提交规范:https://github.com/o-w-o/way/blob/master/appendixs/wiki/git-commit.md"
# 异常退出
exit 1
fi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
上次更新: 2024/08/07, 16:14:27