-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
问题描述
查看历史提交记录,发现 commit message 格式完全不统一:
hjx2289206 的提交(部分)
| 提交 | 问题 |
|---|---|
feat_mobile_optimization |
用下划线代替冒号,不是 conventional commit 格式 |
feat: 添加移动端适配和任务快速移动功能 |
冒号后面有空格 |
feat(导航): 为移动端导航菜单添加可折叠子菜单支持 |
冒号用了中文符号 |
feat: 添加用户活动日志和登录状态管理 |
冒号后面有空格 |
AlkaidSTART 的提交(部分)
| 提交 | 问题 |
|---|---|
解决已知bug |
完全没有 type 前缀 |
新增通知栏滚动逻辑 |
完全没有 type 前缀 |
增加了新建模板功能 |
完全没有 type 前缀 |
新增搜索功能 |
完全没有 type 前缀 |
正确格式参考
Conventional Commit 标准格式:
<type>(<scope>): <subject>
feat(auth): 实现用户登录功能
fix(kanban): 修复拖拽时状态丢失问题
docs(README): 更新安装步骤
- type: feat, fix, docs, style, refactor, perf, test, chore, build, ci
- scope: 所属模块(可选)
- subject: 简短描述,用中文或英文
影响范围
- CHANGELOG 无法自动生成
- 代码历史难以阅读和维护
- 团队协作效率降低
- 无法用
git log --oneline --grep按类型筛选
建议方案
1. 添加 commitlint 配置
npm install --save-dev @commitlint/cli @commitlint/config-conventional.commitlintrc.json:
{
"extends": ["@commitlint/config-conventional"],
"rules": {
"type-enum": [2, "always", ["feat", "fix", "docs", "style", "refactor", "perf", "test", "chore", "build", "ci"]],
"subject-case": [0]
}
}2. 添加 GitHub Actions 检查
.github/workflows/commit-lint.yml:
name: Commit Lint
on:
pull_request:
branches: [main]
jobs:
commit-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: wagoid/commitlint-github-action@v53. 约定
- type 用英文小写
- 冒号用英文
: - scope 可选,用英文或中文
- subject 简洁明了
本 Issue 由 Memo Code 生成。
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels