get-commits

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Git 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 20
Returns 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

在工作流中使用

  1. Changelog: Run script, extract [What] fields, format as Markdown
  2. PR Summary: Run script, extract [Impact] fields, create executive summary
  3. Change Analysis: Run script, filter by type/scope, generate reports
  1. 变更日志:运行脚本,提取[What]字段,格式化为Markdown
  2. PR摘要:运行脚本,提取[Impact]字段,生成执行摘要
  3. 变更分析:运行脚本,按类型/范围筛选,生成报告

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:
    type(scope): title
    or
    type: 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): title
    type: title
  • 标签需单独成行:
    [Why]: ...
    [What]: ...
    [Impact]: ...
  • 所有标签均为可选;缺失的标签将返回空字符串
  • 合并提交将被自动过滤

Script Parameters

脚本参数

bash
python3 scripts/get_commits.py [limit]
  • limit
    (optional): Number of commits to retrieve (default: 50)
bash
python3 scripts/get_commits.py [limit]
  • limit
    (可选):要获取的提交记录数量(默认值:50)

JSON Output Structure

JSON输出结构

Flat, token-efficient structure (no nesting):
FieldDescription
hash
Short commit hash (7 chars)
date
ISO date formatted as YYYY-MM-DD
type
Conventional commit type (feat, fix, etc.)
scope
Component/area affected (empty if missing)
title
Description with type/scope prefix removed
what
Technical details from [What] tag
impact
Business impact from [Impact] tag
扁平化、令牌高效的结构(无嵌套):
字段描述
hash
短提交哈希值(7个字符)
date
ISO格式日期,格式为YYYY-MM-DD
type
规范化提交类型(feat、fix等)
scope
受影响的组件/区域(若缺失则为空)
title
移除type/scope前缀后的描述内容
what
来自[What]标签的技术细节
impact
来自[Impact]标签的业务影响