commit-detection
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCommit Type Detection Skill
提交类型检测技能
Expert knowledge for detecting the optimal conventional commit type.
具备检测最优规范提交类型的专业知识。
Detection Algorithm
检测算法
Step 1: Gather Data
步骤1:收集数据
bash
undefinedbash
undefinedGet modified files
获取修改的文件
git diff --name-only
git diff --staged --name-only
git diff --name-only
git diff --staged --name-only
Get change statistics
获取变更统计信息
git diff --stat
git diff --staged --stat
git diff --stat
git diff --staged --stat
Check for keywords in diff
在差异中查找关键词
git diff | grep -i "fix|bug|error" | head -5
undefinedgit diff | grep -i "fix|bug|error" | head -5
undefinedStep 2: Categorize Files
步骤2:文件分类
| Category | File Patterns |
|---|---|
| docs | |
| test | |
| config | |
| ci | |
| build | |
| style | Only whitespace, formatting changes |
| src | |
| 类别 | 文件模式 |
|---|---|
| 文档 | |
| 测试 | |
| 配置 | |
| CI | |
| 构建 | |
| 格式 | 仅空白字符、格式变更 |
| 源码 | |
Step 3: Apply Rules
步骤3:应用规则
IF only docs files changed:
→ docs
IF only test files changed:
→ test
IF only config/build files changed:
→ chore
IF only CI files changed:
→ ci
IF diff contains "fix", "bug", "error", "issue", "resolve":
→ fix
IF new files added with business logic:
→ feat
IF files renamed/moved without logic change:
→ refactor
IF performance keywords ("optimize", "perf", "speed", "cache"):
→ perf
IF formatting only (whitespace, semicolons):
→ style
DEFAULT:
→ Use /commit-pro:commit for smart analysis如果仅文档文件变更:
→ docs
如果仅测试文件变更:
→ test
如果仅配置/构建文件变更:
→ chore
如果仅CI文件变更:
→ ci
如果差异中包含"fix"、"bug"、"error"、"issue"、"resolve":
→ fix
如果添加了包含业务逻辑的新文件:
→ feat
如果文件重命名/移动但未修改逻辑:
→ refactor
如果包含性能相关关键词("optimize"、"perf"、"speed"、"cache"):
→ perf
如果仅涉及格式调整(空白字符、分号):
→ style
默认:
→ 使用 /commit-pro:commit 进行智能分析Step 4: Determine Scope
步骤4:确定范围
Extract scope from primary directory:
src/components/Button.tsx → ui or button
src/api/auth.ts → auth
lib/utils/date.ts → utils
server/routes/user.ts → user从主目录提取范围:
src/components/Button.tsx → ui 或 button
src/api/auth.ts → auth
lib/utils/date.ts → utils
server/routes/user.ts → userQuick Reference
快速参考
| Type | When |
|---|---|
| New functionality |
| Bug correction |
| Documentation only |
| Formatting only |
| Code restructure |
| Performance |
| Tests only |
| Build/deps |
| CI/CD config |
| Maintenance |
| 类型 | 适用场景 |
|---|---|
| 新增功能 |
| 修复Bug |
| 仅文档变更 |
| 仅格式调整 |
| 代码重构 |
| 性能优化 |
| 仅测试文件变更 |
| 构建/依赖变更 |
| CI/CD配置变更 |
| 日常维护 |
Examples
示例
Example 1: Only README changed
Files: README.md
→ /commit-pro:docsExample 2: New component + test
Files: src/Button.tsx, src/Button.test.tsx
→ /commit-pro:feat (primary is new feature)Example 3: Fix in existing file
Files: src/api/auth.ts
Diff contains: "fix login bug"
→ /commit-pro:fix示例1:仅README文件变更
文件:README.md
→ /commit-pro:docs示例2:新增组件+测试文件
文件:src/Button.tsx, src/Button.test.tsx
→ /commit-pro:feat(主要为新增功能)示例3:修复现有文件中的问题
文件:src/api/auth.ts
差异内容包含:"fix login bug"
→ /commit-pro:fix