examples.md 2.0 KB

Git Commit Analysis Examples

Example 1: Feature Addition Commit

User Request: "帮我分析下这个git提交的修改,要深度分析里面变更的代码内容,而不仅仅是commit 消息:abc123def"

Analysis Output Structure:

# Git Commit 深度分析报告

## 提交信息
- **Commit Hash**: abc123def456...
- **作者**: developer
- **日期**: 2026-02-06
- **提交消息**: "添加用户认证功能"

## 变更概览
- `auth.py`: +150行 (新增认证模块)
- `routes.py`: +30行 (添加登录路由)
- `models.py`: +20行 (用户模型扩展)

## 核心变更详细分析

### 变更1: 用户认证模块
#### 📍 代码位置
`auth.py` 第 1-50 行(新文件)

#### 📝 变更前代码
[文件不存在]

#### 📝 变更后代码

python from flask_jwt_extended import JWTManager, create_access_token from werkzeug.security import check_password_hash

class AuthService:

def __init__(self):
    self.jwt = JWTManager()

def authenticate(self, username, password):
    # 验证逻辑
    ...

#### 🔍 上下文代码
[相关依赖和配置]

#### 💡 变更原因和目的深度分析
1. **业务需求**: 需要保护API端点,防止未授权访问
2. **技术选择**: 使用JWT而非session,支持无状态API
3. **安全性**: 密码使用hash存储,token有过期机制

Example 2: Bug Fix Commit

User Request: "分析这个bug修复提交:xyz789"

Analysis Focus:

  • What bug existed (symptoms, root cause)
  • Why the fix works
  • Edge cases handled
  • Test coverage

Example 3: Refactoring Commit

User Request: "深度分析这个重构提交:refactor123"

Analysis Focus:

  • What was refactored and why
  • Code quality improvements
  • Performance implications
  • Breaking changes

Example 4: Performance Optimization

User Request: "分析这个性能优化提交:perf456"

Analysis Focus:

  • Performance bottleneck identified
  • Optimization technique used
  • Before/after metrics
  • Trade-offs made