本地项目git hooks配置记录

1.commit格式检查hook【mac环境,可重命名项目根目录/.git/hooks/commit_msg.sample为commit_msg,然后用下方内容覆盖即可】【可通过下方git约束模版检查的commit示例:fix(app): fix xxxxx】:

# This example catches duplicate Signed-off-by lines.

message_file = ARGV[0]
message  = File.read(message_file)

$regex = /(^feat|^fix|^docs|^style|^refactor|^test|^chore)\(.*\)\:\s.*/

if !$regex.match(message)
   puts "
\n[Policy] Your message is not formatted correctly
\nSamples:
\nfeat(modulename): what you did.
\nfix(modulename): what you did.
\ndocs(modulename): what you did.
\nstyle(modulename): what you did.
\nrefactor(modulename): what you did.
\ntest(modulename): what you did.
\nchore(modulename): what you did.
\nSee rules https://www.bing.com"
   exit 1
end

2.如果需要配置全局git hooks,可按如下配置:

1.创建/usr/local/.git_template/.git_template目录
2.将第一步中创建的commit_msg文件拷贝至上方目录
3.git config --global init.templatedit /usr/local/.git_template/.git_template使用该命令将git全局配置模版重定向到第一步中创建到目录
4.如上三步完成后即可在创建新的使用git管理的项目的时候自动将全局模版拷贝至项目根目录/.git/目录下,如果完成如上三步后需要对已经存在对git项目使用该模版,可移动至目标项目根目录并执行git init即可

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值