gitlab-hook服务端规范提交邮箱
服务端钩子
https://www.git-scm.com/book/zh/v2/%E8%87%AA%E5%AE%9A%E4%B9%89-Git-Git-%E9%92%A9%E5%AD%90
hook可以分为客户端和服务端
这些钩子都允许你对 git push 的不同阶段做出响应。
- pre-receive
- update
- post-receive
修改custom_hooks_dir路径
vi /etc/gitlab/gitlab.rb
gitlab_shell['custom_hooks_dir'] = /opt/gitlab/embedded/service/gitlab-shell/custom_hooks
sudo gitlab-ctl reconfigure
gitlab-ctl restart//重启gitlab
#!/bin/sh
read new ref
log=$(git log -1 $ref )
em=${log#*<}
email=${em%>*}
temp=${log#*@}
email_suffix=${temp%>*}
if [ ${email_suffix} != 'qq.com' ];then
echo 'you commit code use email is: "'$email '" the suffix of this email is :'${email_suffix}'
Email format error: "'$email'" is not formal qq OA email
can not commit your code , unless follow these steps to modify your email to OA email
steps:1. git config --global --replace-all user.email [email protected]
2. git commit --amend --author "xxx <[email protected]>"
(modify author email to OA email([email protected]) in your commit infos )
3. :wq
attention: if your commit code use email is different from your OA email ([email protected]) ,your code will not statistical'
exit 1
else
echo 'your email is OA email'
exit 0
fi