commit-message
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesecommit-message
提交信息生成
Analyze git changes and generate context-aware commit messages following Conventional Commits.
分析Git变更,生成符合Conventional Commits规范的上下文感知型提交信息。
Quick Start
快速开始
bash
undefinedbash
undefinedAnalyze all changes
分析所有变更
python3 .shared/commit-message/scripts/analyze_changes.py --analyze
python3 .shared/commit-message/scripts/analyze_changes.py --analyze
Get batch commit suggestions
获取批量提交建议
python3 .shared/commit-message/scripts/analyze_changes.py --batch
python3 .shared/commit-message/scripts/analyze_changes.py --batch
Generate message for specific files
为指定文件生成提交信息
python3 .shared/commit-message/scripts/analyze_changes.py --generate "src/api/*.py"
undefinedpython3 .shared/commit-message/scripts/analyze_changes.py --generate "src/api/*.py"
undefinedCommands
命令
| Command | Description |
|---|---|
| Show all changed files with status and categories |
| Suggest how to split changes into multiple commits |
| Generate commit message for matching files |
| Only analyze staged changes (default: all changes) |
| 命令 | 说明 |
|---|---|
| 显示所有变更文件及其状态和分类 |
| 建议如何将变更拆分为多个提交 |
| 为匹配的文件生成提交信息 |
| 仅分析已暂存的变更(默认:所有变更) |
Commit Types
提交类型
| Type | Description | Example |
|---|---|---|
| New feature | |
| Bug fix | |
| Code restructuring | |
| Documentation | |
| Tests | |
| Maintenance | |
| Formatting | |
| 类型 | 说明 | 示例 |
|---|---|---|
| 新功能 | |
| 修复Bug | |
| 代码重构 | |
| 文档更新 | |
| 测试相关 | |
| 维护工作 | |
| 代码格式调整 | |
Batch Commit Workflow
批量提交流程
When you have multiple unrelated changes:
- Run to see suggested commit groups
--batch - Stage files for first commit:
git add <files> - Commit with suggested message
- Repeat for remaining groups
当你有多个不相关的变更时:
- 运行 查看建议的提交分组
--batch - 暂存第一个提交的文件:
git add <files> - 使用建议的信息提交
- 对剩余分组重复上述步骤
Grouping Strategy
分组策略
Files are grouped by:
- Directory/Module: ,
src/api/,tests/docs/ - Change Type: Added vs Modified vs Deleted
- Semantic Relationship: Related files together
文件将按照以下规则分组:
- 目录/模块:,
src/api/,tests/docs/ - 变更类型:新增、修改或删除
- 语义关联:将相关文件归为一组
Context-Aware Commit Messages
上下文感知型提交信息
Note: Thescript provides file grouping and basic suggestions. Use its output as a starting point, then readanalyze_changes.pyto understand the actual changes and generate context-aware messages following the examples below.git diff
When generating commit messages, analyze the actual code changes to infer business context. Don't just describe files—describe what the changes accomplish.
注意:脚本提供文件分组和基础建议。请将其输出作为起点,然后查看analyze_changes.py以了解实际变更,并参照以下示例生成上下文感知型提交信息。git diff
生成提交信息时,请分析实际代码变更以推断业务上下文。不要仅描述文件,要说明变更实现的功能。
Scope Guidelines
范围指南
The scope should reflect the business module or feature, not just the directory:
| Scope Type | Example | When to Use |
|---|---|---|
| Feature/Module | | Changes to a specific product feature |
| Platform | | Platform-specific changes |
| Integration | | Third-party integration changes |
| Component | | Core infrastructure changes |
范围应反映业务模块或功能,而不仅仅是目录:
| 范围类型 | 示例 | 使用场景 |
|---|---|---|
| 功能/模块 | | 针对特定产品功能的变更 |
| 平台 | | 特定平台的变更 |
| 集成 | | 第三方集成相关的变更 |
| 组件 | | 核心基础设施组件的变更 |
Input/Output Examples
输入/输出示例
Example 1: New Feature
Input (code changes):
+ src/companion/pages/AvailabilityDetailPage.tsx
+ src/companion/pages/AvailabilityActionsPage.tsx
+ src/companion/components/AvailabilityCard.tsx
M src/companion/navigation/routes.ts
Output:
feat(companion): add availability detail and actions pages for ios
- New AvailabilityDetailPage showing time slot details
- New AvailabilityActionsPage for booking/canceling
- AvailabilityCard component for list display
- Updated navigation routesExample 2: Bug Fix
Input (code changes):
M src/integrations/outlook/email_sender.py
M src/integrations/outlook/auth.py
Output:
fix(outlook): resolve email sending failures due to token expiration
Refresh OAuth token before sending when close to expiryExample 3: Multi-platform Change
Input (code changes):
M ios/Calendar/CalendarView.swift
M android/calendar/CalendarFragment.kt
M web/src/calendar/Calendar.tsx
Output:
feat(calendar): add week view across all platforms
Implement consistent week view UI for iOS, Android, and webExample 4: Chore/Maintenance
Input (code changes):
M package.json
M yarn.lock
M requirements.txt
Output:
chore(deps): update dependencies to latest versions示例1:新功能
输入(代码变更):
+ src/companion/pages/AvailabilityDetailPage.tsx
+ src/companion/pages/AvailabilityActionsPage.tsx
+ src/companion/components/AvailabilityCard.tsx
M src/companion/navigation/routes.ts
输出:
feat(companion): add availability detail and actions pages for ios
- New AvailabilityDetailPage showing time slot details
- New AvailabilityActionsPage for booking/canceling
- AvailabilityCard component for list display
- Updated navigation routes示例2:Bug修复
输入(代码变更):
M src/integrations/outlook/email_sender.py
M src/integrations/outlook/auth.py
输出:
fix(outlook): resolve email sending failures due to token expiration
Refresh OAuth token before sending when close to expiry示例3:跨平台变更
输入(代码变更):
M ios/Calendar/CalendarView.swift
M android/calendar/CalendarFragment.kt
M web/src/calendar/Calendar.tsx
输出:
feat(calendar): add week view across all platforms
Implement consistent week view UI for iOS, Android, and web示例4:维护工作
输入(代码变更):
M package.json
M yarn.lock
M requirements.txt
输出:
chore(deps): update dependencies to latest versionsWriting Good Descriptions
撰写优质描述的技巧
| Bad (Generic) | Good (Context-Aware) |
|---|---|
| |
| |
| |
| |
| 不佳(通用表述) | 优秀(上下文感知) |
|---|---|
| |
| |
| |
| |
Key Principles
核心原则
- Read the code - Understand what the changes actually do
- Identify the feature - What user-facing or system capability is affected?
- Be specific - Include relevant details (platform, integration, component)
- Use active voice - "add", "fix", "update", not "added", "fixed", "updated"
- Keep it concise - First line under 72 characters
- 阅读代码 - 理解变更的实际作用
- 识别功能 - 哪些用户可见或系统能力受到影响?
- 具体明确 - 包含相关细节(平台、集成、组件)
- 使用主动语态 - 使用“add”“fix”“update”而非“added”“fixed”“updated”
- 保持简洁 - 第一行不超过72个字符