Loading...
Loading...
Chinese Git Commit Specification - Commit Message Standards and Changelog Automation Adapted for Domestic Teams
npx skill4agent add jnmetacode/superpowers-zh chinese-commit-conventions| Type | Description | Example Scenarios |
|---|---|---|
| New Feature | Add user registration module |
| Bug Fix | Fix white screen issue on login page |
| Documentation Change | Update API documentation |
| Code Formatting (no logic impact) | Adjust indentation, add missing semicolons |
| Refactoring (not new feature or bug fix) | Split overly long service classes |
| Performance Optimization | Optimize homepage list query speed |
| Testing-related | Add unit tests for user module |
| Build/Tool/Dependency Change | Upgrade webpack to v5 |
| CI Configuration | Modify GitHub Actions workflow |
| Revert Commit | Revert login refactor in v2.1.0 |
typescopedescriptionbody<type>(<scope>): <subject>
<body>
<footer>feat(用户模块): 添加手机号一键登录功能
- 接入运营商一键登录 SDK
- 支持移动、联通、电信三网
- 登录失败自动降级到短信验证码
Closes #128fix(订单): 修复并发下单导致库存超卖的问题
在高并发场景下,原有的库存扣减逻辑存在竞态条件。
改用 Redis 分布式锁 + 数据库乐观锁双重保障。
影响范围:订单服务、库存服务
测试确认:已通过 500 并发压测验证
Closes #256<type>(<scope>): <description>用户模块订单支付基础组件feat(权限): 添加基于 RBAC 的细粒度权限控制
fix(支付): 修复微信支付回调签名验证失败的问题
perf(列表页): 优化大数据量表格的虚拟滚动渲染
refactor(网关): 将单体网关拆分为独立微服务# Avoid the following writing styles
fix: 修了一个 bug
feat: 更新代码
chore: 改了点东西<Change background and reason>
Technical Solution:
- <Solution point 1>
- <Solution point 2>
Impact Scope: <Affected modules or services>feat(接口): 重构用户信息返回结构
将用户接口返回的扁平结构改为嵌套结构,前端需同步调整字段取值路径。
BREAKING CHANGE: /api/user/info 返回结构变更
- avatar 字段移入 profile 对象
- 移除已废弃的 nickname 字段,统一使用 displayNamefeat(接口)!: 重构用户信息返回结构Closes #128
Refs #129, #130Closes #I5ABC1
相关需求: https://gitee.com/org/repo/issues/I5ABC1关联 Coding 缺陷 #12345
fixed=project-2024/issues/678# Associate multiple platforms in footer
Closes #128
Jira: PROJ-456
禅道: #789npm install -D conventional-changelog-cli conventional-changelog-conventionalcommits{
"scripts": {
"changelog": "conventional-changelog -p conventionalcommits -i CHANGELOG.md -s",
"changelog:all": "conventional-changelog -p conventionalcommits -i CHANGELOG.md -s -r 0",
"release": "standard-version"
}
}module.exports = {
types: [
{ type: 'feat', section: '新功能' },
{ type: 'fix', section: '缺陷修复' },
{ type: 'perf', section: '性能优化' },
{ type: 'refactor', section: '代码重构' },
{ type: 'docs', section: '文档更新' },
{ type: 'test', section: '测试' },
{ type: 'chore', section: '构建/工具', hidden: true },
{ type: 'ci', section: '持续集成', hidden: true },
{ type: 'style', section: '代码格式', hidden: true }
],
commitUrlFormat: '{{host}}/{{owner}}/{{repository}}/commit/{{hash}}',
compareUrlFormat: '{{host}}/{{owner}}/{{repository}}/compare/{{previousTag}}...{{currentTag}}'
}npm install -D @commitlint/cli @commitlint/config-conventionalmodule.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [2, 'always', [
'feat', 'fix', 'docs', 'style', 'refactor',
'perf', 'test', 'chore', 'ci', 'revert'
]],
'type-case': [2, 'always', 'lower-case'],
'type-empty': [2, 'never'],
'subject-empty': [2, 'never'],
'subject-max-length': [2, 'always', 100],
// Allow Chinese characters, disable subject-case restriction
'subject-case': [0],
// Disable header-max-length or relax it (Chinese occupies more width)
'header-max-length': [2, 'always', 120],
'body-max-line-length': [1, 'always', 200],
'footer-max-line-length': [1, 'always', 200]
},
prompt: {
messages: {
type: '选择提交类型:',
scope: '输入影响范围(可选):',
subject: '填写简短描述:',
body: '填写详细描述(可选,使用 "|" 换行):',
breaking: '列出不兼容变更(可选):',
footer: '关联的 Issue(可选,例如 #123):',
confirmCommit: '确认提交以上信息?'
}
}
}npm install -D husky lint-staged
npx husky init# .husky/commit-msg
npx --no -- commitlint --edit "$1"# .husky/pre-commit
npx lint-staged{
"lint-staged": {
"*.{js,ts,jsx,tsx,vue}": [
"eslint --fix",
"prettier --write"
],
"*.{css,scss,less}": [
"stylelint --fix",
"prettier --write"
],
"*.md": [
"prettier --write"
]
}
}npm install -D commitizen cz-conventional-changelog
# Add to package.json
{
"config": {
"commitizen": {
"path": "cz-conventional-changelog"
}
},
"scripts": {
"commit": "cz"
}
}npm run committypescopesubjectsubjectbody.commitlintrc.husky/