优化git commit message
使用commitizen进行提交
一、初始化
npm install -g commitizen |
然后使用git cz
替代commit
二、汉化(自定义模版)
https://github.com/leoforfree/cz-customizable#steps
安装适配器
npm install cz-customizable --save-dev
修改工程根目录下
package.json
文件
将"path": "./node_modules/cz-customizable/"
改为"./node_modules/cz-customizable"
"config": {
"commitizen": {
"path": "./node_modules/cz-customizable"
}
}在根目录下创建
.cz-config.js
文件
可以参考官方的cz-config-EXAMPLE.js;
module.exports = {
types: [
{value: '特性', name: '特性: 一个新的特性'},
{value: '修复', name: '修复: 修复一个Bug'},
{value: '文档', name: '文档: 变更的只有文档'},
{value: '格式', name: '格式: 空格, 分号等格式修复'},
{value: '重构', name: '重构: 代码重构,注意和特性、修复区分开'},
{value: '性能', name: '性能: 提升性能'},
{value: '测试', name: '测试: 添加一个测试'},
{value: '工具', name: '工具: 开发工具变动(构建、脚手架工具等)'},
{value: '回滚', name: '回滚: 代码回退'}
],
scopes: [
{name: 'app'},
{name: 'Demo'},
{name: 'Frame'},
{name: 'KeepassApi'},
{name: 'IBaseApi'},
{name: 'HWImp'},
{name: 'PlayImp'}
],
allowTicketNumber: false,
isTicketNumberRequired: false,
ticketNumberPrefix: 'TICKET-',
ticketNumberRegExp: '\\d{1,5}',
// it needs to match the value for field type. Eg.: 'fix'
/*
scopeOverrides: {
fix: [
{name: 'merge'},
{name: 'style'},
{name: 'e2eTest'},
{name: 'unitTest'}
]
},
*/
// override the messages, defaults are as follows
messages: {
type: '选择一种你的提交类型:',
scope: '选择一个scope (可选):',
// used if allowCustomScopes is true
customScope: 'Denote the SCOPE of this change:',
subject: '短说明:\n',
body: '长说明,使用"|"换行(可选):\n',
breaking: '非兼容性说明 (可选):\n',
footer: '关联关闭的issue,例如:#31, #34(可选):\n',
confirmCommit:'确定提交说明?'
},
allowCustomScopes: true,
allowBreakingChanges: ['特性', '修复'],
// skip any questions you want
skipQuestions: ['body'],
// limit subject length
subjectLimit: 100
};执行命令
echo '{ "path": "cz-customizable" }' > ~/.czrc
其它
优化git commit message