Commitizen 辅助git规范化提交

第一步:全局安装commitizen

yarn global add commitizen@4.2.4

第二部:安装cz-customizable@6.3.0

yarn add cz-customizable@6.3.0 -S

第三部:配置package.json,插入代码:

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

第四部:项目根目录添加 .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'],
    // 默认长度72 简要描述的长度限制
    subjectLimit: 72
}

第五步:使用 git cz 代替 git commit

执行git cz

 

 

完成。

 

posted @ 2021-12-11 22:37  Mr_R  阅读(149)  评论(0编辑  收藏  举报