You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
980 B
31 lines
980 B
#!/bin/sh
|
|
|
|
# 用 `` 可以将命令的输出结果赋值给变量
|
|
# 获取当前提交的 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 "\n不合法的 commit 消息提交格式,请使用正确的格式:\
|
|
\nfeat: add comments\
|
|
\nfix: handle events on blur (close #28)\
|
|
\n详情请查看 git commit 提交规范:https://github.com/woai3c/Front-end-articles/blob/master/git%20commit%20style.md"
|
|
|
|
# 异常退出
|
|
exit 1
|
|
fi
|
|
|
|
# 对用户权限做判断则比较简单,只需要检查用户的邮箱或用户名就可以了
|
|
#(假设现在只有 abc 公司的员工才有权限提交代码)。
|
|
email_re="@abc\.com"
|
|
if [[ ! $email =~ $email_re ]]
|
|
then
|
|
echo "此用户没有权限,具有权限的用户为: xxx@abc.com"
|
|
|
|
# 异常退出
|
|
exit 1
|
|
fi
|