关于git:Git规范Commitizen

11次阅读

共计 1089 个字符,预计需要花费 3 分钟才能阅读完成。

Conventional Commits specification(约定式提交)

  <type>[optional scope]: <description>

  [optional body]

  [optional footer(s)]

  ------ 翻译 ------
  
  < 类型 >[可选 范畴]:< 形容 >

  [可选 注释]

  [可选 脚注]

应用 Commitizen 进行代码提交 (git commit) 时 commitizen 会提交你在提交时填写所有必须的提交字段。

  1. 全局装置 Commitizen

     npm install -g commitizen
  2. 装置并配置 cz-customizable 插件
    1) 应用 npm 下载 cz-customizable

    npm i cz-customizable --save-dev

    2) 增加以下配置到 package.json 中

    "config": {
      "commitizen": {"path": "node_modules/cz-customizable"}
    }
  3. 在我的项目根目录下创立 .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)'
        },
        // 跳过问题
        skipQuestions: ['body', 'footer'],
        // subject 文字长度默认是 72
        subjectLimit: 72
    };
  4. 应用 git cz代替 git commit
正文完
 0