← 返回
未分类 中文

Commit Diff Analyzer

Analyzes code changes between two git commits. Use when user provides two commit IDs and wants to understand what changed between them, including file modifi...
分析两次 Git 提交之间的代码变更。用户提供两个提交 ID 时使用,用于了解两者之间的改动,包括文件修改等。
afine907
未分类 clawhub v1.0.0 1 版本 99570.8 Key: 无需
★ 0
Stars
📥 232
下载
💾 0
安装
1
版本
#latest

概述

Commit Diff Analyzer

Usage Pattern

When user provides two commit IDs (in any order or format), analyze the changes between them:

  1. Validate commits exist: Run git cat-file -t for each commit ID
  2. Get commit info: Run git log -1 --format=fuller for both commits
  3. Show diff: Run git diff .. (chronological order)
  4. Show stats: Run git diff --stat ..

Output Organization

Present the analysis with:

  1. Commit metadata - Author, date, commit message for both commits
  2. Change summary - Files changed, insertions, deletions
  3. Detailed diff - Line-by-line changes with context
  4. File breakdown - Group by: Modified, Added, Deleted files

Key Commands

# Validate commits exist
git cat-file -t <commit-id>

# Get full commit info
git log -1 --format="Hash: %H%nAuthor: %an%nDate: %ad%nMessage: %s%n" <commit-id>

# Chronological diff (older..newer)
git diff <older-commit>..<newer-commit>

# Diff stat
git diff --stat <older-commit>..<newer-commit>

# Show files changed
git diff --name-only <older-commit>..<newer-commit>

Handling Edge Cases

  • Invalid commit IDs: Report error and suggest running git log to see recent commits
  • Same commit: Notify user both IDs point to the same commit
  • Non-git directory: Error - skill only works in git repositories
  • Reverse order: Detect which commit is older and adjust command accordingly

Commit ID Formats

Accept various formats:

  • Full SHA: abc123def456...
  • Short SHA: abc123d (at least 7 chars)
  • Branch names (if they point to commits)
  • HEAD references like HEAD~5

Example Output Structure

=== Commit A ===
Hash: abc123...
Author: John Doe
Date: 2024-01-15 10:30:00
Message: feat: add user login

=== Commit B ===
Hash: def456...
Author: Jane Smith
Date: 2024-01-20 14:45:00
Message: fix: resolve auth bug

=== Changes Summary ===
5 files changed, 120 insertions(+), 35 deletions(-)

=== File Breakdown ===
Modified: src/auth.js, src/login.html
Added: src/auth-utils.ts
Deleted: src/old-auth.php

=== Diff ===
... (detailed diff output)

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-21 15:38 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

AI Commit Message Generator

afine907
分析暂存的更改并自动生成语义化的提交信息。读取 git diff --staged,分析代码更改,生成符合约定的提交信息。
★ 0 📥 263

Linux Ops

afine907
Linux运维速查:进程管理、日志分析、网络诊断、性能监控、用户管理。
★ 0 📥 266

Python Testing

afine907
Python 测试速查:运行 pytest、使用 mock/patch、参数化、fixtures、异步、覆盖率测试。
★ 0 📥 335