get-commits
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGit Changelog Parser
Git 变更日志解析器
Parse local git commit history into clean, structured JSON.
Extracts conventional commit metadata, custom tags
([Why], [What], [Impact]), and returns a token-efficient flat
structure ready for documentation workflows.
将本地Git提交历史解析为简洁、结构化的JSON格式。提取规范化提交元数据、自定义标签([Why]、[What]、[Impact]),并返回一个令牌高效的扁平化结构,可直接用于文档工作流。
Quick Start
快速开始
bash
python3 scripts/get_commits.py 20Returns JSON with last 20 commits:
json
[
{
"hash": "abc1234",
"date": "2026-02-09",
"type": "feat",
"scope": "auth",
"title": "Add JWT authentication",
"what": "Implemented JWT tokens with refresh mechanism",
"impact": "Breaking change: auth endpoints require tokens"
}
]bash
python3 scripts/get_commits.py 20返回包含最近20条提交记录的JSON:
json
[
{
"hash": "abc1234",
"date": "2026-02-09",
"type": "feat",
"scope": "auth",
"title": "Add JWT authentication",
"what": "Implemented JWT tokens with refresh mechanism",
"impact": "Breaking change: auth endpoints require tokens"
}
]Use in your workflow
在工作流中使用
- Changelog: Run script, extract [What] fields, format as Markdown
- PR Summary: Run script, extract [Impact] fields, create executive summary
- Change Analysis: Run script, filter by type/scope, generate reports
- 变更日志:运行脚本,提取[What]字段,格式化为Markdown
- PR摘要:运行脚本,提取[Impact]字段,生成执行摘要
- 变更分析:运行脚本,按类型/范围筛选,生成报告
Commit Message Format
提交消息格式
The script expects commits following this structure:
feat(scope): Brief description
[Why] Reason for this change
[What] Technical implementation details
[Impact] Business impact or breaking changes- First line: or
type(scope): titletype: title - Tags on separate lines: ,
[Why]: ...,[What]: ...[Impact]: ... - All tags are optional; missing tags return empty strings
- Merge commits are filtered out automatically
脚本要求提交消息遵循以下结构:
feat(scope): Brief description
[Why] Reason for this change
[What] Technical implementation details
[Impact] Business impact or breaking changes- 首行:或
type(scope): titletype: title - 标签需单独成行:、
[Why]: ...、[What]: ...[Impact]: ... - 所有标签均为可选;缺失的标签将返回空字符串
- 合并提交将被自动过滤
Script Parameters
脚本参数
bash
python3 scripts/get_commits.py [limit]- (optional): Number of commits to retrieve (default: 50)
limit
bash
python3 scripts/get_commits.py [limit]- (可选):要获取的提交记录数量(默认值:50)
limit
JSON Output Structure
JSON输出结构
Flat, token-efficient structure (no nesting):
| Field | Description |
|---|---|
| Short commit hash (7 chars) |
| ISO date formatted as YYYY-MM-DD |
| Conventional commit type (feat, fix, etc.) |
| Component/area affected (empty if missing) |
| Description with type/scope prefix removed |
| Technical details from [What] tag |
| Business impact from [Impact] tag |
扁平化、令牌高效的结构(无嵌套):
| 字段 | 描述 |
|---|---|
| 短提交哈希值(7个字符) |
| ISO格式日期,格式为YYYY-MM-DD |
| 规范化提交类型(feat、fix等) |
| 受影响的组件/区域(若缺失则为空) |
| 移除type/scope前缀后的描述内容 |
| 来自[What]标签的技术细节 |
| 来自[Impact]标签的业务影响 |