VUE git 约定规范 Commitizen 和 GIT HOOKS

Posted 咸咸瑜瑜

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了VUE git 约定规范 Commitizen 和 GIT HOOKS相关的知识,希望对你有一定的参考价值。

对于git提交规范 来说,不同的团队可能会有不同的标准

VUE

 

 

我们要学习的commitizen就是其中的佼 佼者!commitizen仓库名为 ,它提供了个git cz的指令于代替git commit,简单句话介绍它: 当你使commitizen进代码提交(git commit)时,commitizen会提交你在提交时填写所有必需的提 交字段!这句话怎么解释呢?不着急,下我们就来安装并且使下commitizen,使完成之后你然就明 了这句话的意思!

全局安装把:

npm install -g commitizen@4.2.4

然后安装和配置 cz-customizable 插件

npm i cz-customizable@6.3.0 --save-dev

添加以下配置到 package.json 中

VUEVUE

"config": 
"commitizen":
"path":"node_modules/cz-customizable"

View Code

VUE


 

然后项根录下创建.cz-config.js自定义提交内容

VUEVUE

module.exports = 
// 可选类型
types: [
value: feat, name: feat: 新功能 ,
value: fix, name: fix: 修复 ,
value: docs, name: docs: 文档变更 ,
value: style, name: style: 代码格式(不影响代码运行的变动) ,

value: refactor,
name: refactor: 重构(既不是增加feature,也不是修复bug)
,
value: perf, name: perf: 性能优化 ,
value: test, name: test: 增加测试 ,
value: chore, name: chore: 构建过程或辅助工具的变动 ,
value: revert, name: revert: 回退 ,
value: build, name: build: 打包
],
// 消息步骤
messages:
type: 请选择提交类型:,
customScope: 请输入修改范围(可选):,
subject: 请简要描述提交(必填):,
body: 请输入详细描述(可选):,
footer: 请输入要关闭的issue(可选):,
confirmCommit: 确认使用以上信息提交?(y/n/e/h)
,
// 跳过问题
skipQuestions: [body, footer],
// subject文字长度默认是72
subjectLimit: 72

View Code

 

然后我们就可以尝试

git add .

git cz 

我们 git cz 是代替了 git commit -m xxx

VUE

他会问你一堆东西,其实就是你自己配置的。

 

 

 如果你忘记了用 git cz 提交咋个办?  解决方法来了:GITHOOKS:

git 钩子嘛。。。

 

阻止不合规的Git提交信息,那么就拦截报错。

主要用的就2个:

VUE

 

 VUE

 


本文来自博客园,作者:​​咸瑜​​​,转载请注明原文链接:​​javascript:void(0)p/16335777.html​


以上是关于VUE git 约定规范 Commitizen 和 GIT HOOKS的主要内容,如果未能解决你的问题,请参考以下文章

简单使用Commitizen-规范你的commit message

cz-git 强大的 commitizen 的适配器——我的开发心路历程

15分钟快速配置eslint,prettier,lint-staged,husky,commitizen实现前端项目代码规范化

commitizen -- git cz

使用“npx git-cz”时如何定义Commitizen适配器?

如何在使用“npx git-cz”时定义Commitizen适配器?