美文网首页
Commitizen规范化提交代码

Commitizen规范化提交代码

作者: 媛猿YY | 来源:发表于2022-03-10 17:16 被阅读0次

commitizen 仓库名为 cz-cli ,它提供了一个 git cz 的指令用于代替 git commit,简单一句话介绍它:

  • 当你使用 commitizen 进行代码提交(git commit)时,commitizen 会提交你在提交时填写所有必需的提交字段!
  1. 全局安装Commitizen
npm install -g commitizen@4.2.4
  1. 安装并配置 cz-customizable 插件
    2-1. 使用 npm 下载 cz-customizable
npm i cz-customizable@6.3.0 --save-dev

2-2. 添加以下配置到 package.json 中

 "config": {
    "commitizen": {
      "path": "node_modules/cz-customizable"
    }
  }
  1. 项目根目录下创建 .cz-config.js 自定义提示文件
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
}
  1. 使用 git cz 代替 git commit 使用 git cz 代替 git commit,即可看到提示内容


    image.png

相关文章

  • Commitizen规范化提交代码

    commitizen 仓库名为 cz-cli[https://github.com/commitizen/cz-c...

  • Git代码提交规范

    一、代码提交规范化的目的 为了部门提交代码信息格式规范化 为了更好的追溯代码、筛选 为了更加快速的定位提交代码所涉...

  • 前端编程规范化

    1、代码检测工具: ESLint2、代码格式化工具: Prettier3、约定式提交规范:commitizen +...

  • 规范git 提交

    使用 commitizen包来管理提交 安装pkg 添加配置 配置脚本

  • 用Commitizen来规范你的代码提交

    平时提交的变动信息是应该遵循 Angular 规范 的,标准格式为: 提交说明包含了下面的结构化元素,以向类库使用...

  • AndroidStudio插件-Git Commit Templ

    为了规范化团队代码提交,可以使用Git Commit Template插件对git提交规范进行一定的约束,方便后期...

  • git日志提交规范

    安装日志提交工具 https://github.com/commitizen/cz-cli[https://git...

  • 前端项目接入git提交信息规范

    目的 规范化代码提交流程,让changelog看起来更清晰,适合大型项目合作开发,利于项目维护和提交检查 mess...

  • Git学习笔记-多人协作

    多人协作使用Git的基本约定 一. 按规定格式提交 commit message 使用 commitizen 等工...

  • 使用 commitizen 优化 git 提交

    之前写了一篇博客,用来做备忘,每次有新项目的时候,就上去复制粘贴: 关于项目 git 协作流程的思考 但是因为有一...

网友评论

      本文标题:Commitizen规范化提交代码

      本文链接:https://www.haomeiwen.com/subject/bwzfdrtx.html