AlfieriChou / alfierichou.github.io

AlfieriChou的博客
https://alfierichou.com
4 stars 0 forks source link

git hooks #22

Open AlfieriChou opened 2 years ago

AlfieriChou commented 2 years ago
  1. pre-commit
#!/bin/sh
npm run lint

exitCode="$?"
exit $exitCode
  1. commit-msg
#!/bin/sh

commit_msg=`cat $1`

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 消息提交格式,请使用正确的格式:"
    echo "feat: add comments"
    echo "fix: handle events on blur (close #28)"
    exit 1
fi

email_re="@qq\.com"
if [[ ! $email =~ $email_re ]]
then
    echo "此用户没有权限,具有权限的用户为: xxx@qq.com"
    exit 1
fi