Skip to content

Latest commit

 

History

History
425 lines (330 loc) · 16.8 KB

File metadata and controls

425 lines (330 loc) · 16.8 KB

📚 Git Summarizer Examples

This document contains detailed examples of Git Summarizer output and use cases.


📖 Table of Contents


Basic Usage

Analyzing the Current Directory

$ gitsum summarize .

Analyzing a Specific Repository

$ gitsum summarize ~/projects/my-awesome-app

Limiting Commits for Faster Analysis

$ gitsum summarize . --limit-commits 200

🌐 Remote Repository Analysis

Git Summarizer can analyze any public Git repository directly from its URL.

GitHub Repositories

# Analyze FastAPI
$ gitsum summarize https://github.com/fastapi/fastapi

# Analyze with shallow clone (faster)
$ gitsum summarize https://github.com/tiangolo/fastapi --shallow

# Custom clone depth for balance of speed and history
$ gitsum summarize https://github.com/python/cpython --clone-depth 1000

GitLab Repositories

$ gitsum summarize https://gitlab.com/gitlab-org/gitlab-runner

BitBucket Repositories

$ gitsum summarize https://bitbucket.org/atlassian/python-bitbucket

Sample Remote Analysis Output

$ gitsum summarize https://github.com/psf/requests --shallow --no-llm

╔═══════════════════════════════════════════════════════════════╗
║   ██████╗ ██╗████████╗███████╗██╗   ██╗███╗   ███╗           ║
║  ...                                                          ║
╚═══════════════════════════════════════════════════════════════╝

Cloning repository: https://github.com/psf/requests
✓ Cloned to temporary directory
Analyzing remote repository: https://github.com/psf/requests

✓ Loaded 100 commits

═════════════════════════════════════════════════════════════════

╭──────────────────── 📜 Git History Summary ────────────────────╮
│ ╭────────────────────┬─────────────────────────────────╮       │
│ │ 📊 Total Commits   │ 100                             │       │
│ │ 👥 Contributors    │ 34                              │       │
│ │ ...                                                  │       │
│ ╰────────────────────┴─────────────────────────────────╯       │
╰────────────────────────────────────────────────────────────────╯

...

Cleaned up temporary files
Analysis completed at 2024-11-24 10:45:32

Tips for Remote Analysis

Flag Use Case
--shallow Quick overview, uses last 100 commits
--clone-depth 500 Balance of speed and history depth
--limit-commits 200 Process only recent commits after full clone
--no-llm Skip LLM for faster results

Summary Styles

Executive Summary

Perfect for non-technical stakeholders:

$ gitsum summarize . --style executive

Sample Output:

╭───────────────────────── 🤖 AI Summary ─────────────────────────╮
│                                                                  │
│ # Executive Summary                                              │
│                                                                  │
│ This repository is a **healthy, actively maintained project**   │
│ with consistent development patterns over the past 2 years.     │
│                                                                  │
│ ## Key Metrics                                                   │
│ - **1,247 commits** from **23 contributors**                    │
│ - Average of **6.5 commits per week**                           │
│ - **156K lines added**, **89K lines removed**                   │
│                                                                  │
│ ## Health Indicators                                             │
│ ✅ Regular commit activity                                       │
│ ✅ Diverse contributor base                                      │
│ ⚠️ 3 files identified as high-risk                              │
│ ⚠️ Bus factor of 3 (moderate risk)                              │
│                                                                  │
│ ## Recommendations                                               │
│ 1. Review `engine.py` - highest risk score                      │
│ 2. Consider knowledge sharing for critical files                 │
│ 3. Address the 45-day inactive period pattern                   │
│                                                                  │
╰──────────────────────────────────────────────────────────────────╯

Technical Summary

Detailed analysis for developers:

$ gitsum summarize . --style technical

Sample Output:

╭───────────────────────── 🤖 AI Summary ─────────────────────────╮
│                                                                  │
│ # Technical Analysis                                             │
│                                                                  │
│ ## Architecture Observations                                     │
│                                                                  │
│ The codebase follows a modular architecture with clear           │
│ separation of concerns:                                          │
│                                                                  │
│ ```                                                              │
│ src/                                                             │
│ ├── core/      # High churn - 45% of all changes                │
│ ├── api/       # Stable - mostly feature additions              │
│ ├── utils/     # Moderate churn - needs attention               │
│ └── tests/     # Good coverage growth                           │
│ ```                                                              │
│                                                                  │
│ ## Technical Debt Indicators                                     │
│                                                                  │
│ 1. **engine.py** (Risk: 87.3)                                   │
│    - 156 changes from 8 authors                                 │
│    - High complexity score                                       │
│    - Consider refactoring into smaller modules                  │
│                                                                  │
│ 2. **handlers.py** (Risk: 72.1)                                 │
│    - Growing complexity                                          │
│    - Mixed concerns - API + business logic                      │
│                                                                  │
│ ## Commit Patterns                                               │
│                                                                  │
│ - 25% fix commits → Technical debt accumulation                 │
│ - 16% feat commits → Healthy feature development                │
│ - 10% refactor → Good maintenance habits                        │
│                                                                  │
│ ## Recommendations                                               │
│                                                                  │
│ 1. Split `engine.py` into:                                      │
│    - `core/processing.py`                                       │
│    - `core/validation.py`                                       │
│    - `core/transforms.py`                                       │
│                                                                  │
│ 2. Add integration tests for API handlers                       │
│                                                                  │
│ 3. Document the 8-contributor workflow for engine.py            │
│                                                                  │
╰──────────────────────────────────────────────────────────────────╯

Risk-Focused Summary

For security and risk assessment:

$ gitsum summarize . --style risk

Risk Analysis

Understanding Risk Scores

Risk scores range from 0-100 and are calculated based on:

Factor Weight Description
Change Frequency 30% How often the file changes
Lines Changed 20% Total code churn
Author Count 15% Number of contributors
Recency 20% Recent changes = higher risk
Complexity 15% Estimated code complexity

Sample Risk Table

            ⚠️ Riskiest Files
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ File                          ┃ Risk  ┃ Changes ┃ Authors ┃ Factors                  ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ src/core/engine.py            │  87.3 │     156 │       8 │ High frequency, Complex  │
│ src/api/handlers.py           │  72.1 │      89 │       6 │ Many contributors        │
│ src/utils/helpers.py          │  65.4 │      67 │       5 │ Heavy churn              │
│ src/models/user.py            │  54.2 │      45 │       4 │ Recently modified        │
│ src/services/auth.py          │  48.7 │      38 │       3 │ Security-sensitive       │
│ config/settings.py            │  42.1 │      32 │       5 │ Configuration drift      │
│ src/db/migrations.py          │  38.5 │      28 │       2 │ DB changes               │
│ src/api/middleware.py         │  35.2 │      24 │       3 │ Moderate risk            │
│ tests/test_engine.py          │  28.9 │      22 │       4 │ Test coverage gaps       │
│ src/utils/validators.py       │  25.1 │      18 │       2 │ Low risk                 │
└───────────────────────────────┴───────┴─────────┴─────────┴──────────────────────────┘

Contributor Analysis

Developer Hotspots

            👥 Developer Hotspots
┏━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Contributor        ┃ Commits ┃ Lines +  ┃ Lines -  ┃ Expertise                    ┃
┡━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ Alice Johnson      │     312 │  +45,234 │  -12,456 │ src/core, src/api            │
│ Bob Smith          │     256 │  +32,100 │  -18,900 │ src/utils, tests             │
│ Charlie Brown      │     189 │  +28,450 │  -15,230 │ src/services                 │
│ Diana Prince       │     134 │  +18,900 │   -8,450 │ src/models, config           │
│ Edward Chen        │      98 │  +12,340 │   -6,780 │ src/api                      │
│ Fiona Green        │      87 │   +9,870 │   -4,560 │ docs, tests                  │
│ George Wilson      │      65 │   +5,430 │   -2,340 │ src/db                       │
│ Hannah Lee         │      54 │   +4,210 │   -1,890 │ src/utils                    │
└────────────────────┴─────────┴──────────┴──────────┴──────────────────────────────┘

  🚌 Bus Factor: 3

Understanding Bus Factor

The bus factor indicates how many contributors would need to leave before the project stalls:

Bus Factor Risk Level Interpretation
1 🔴 Critical Single point of failure
2-3 🟡 Moderate Some concentration risk
4-5 🟢 Healthy Well-distributed knowledge
6+ 🟢 Excellent Resilient team

JSON Output

Export analysis for integration with other tools:

$ gitsum summarize . --json analysis.json

Sample JSON Structure

{
  "repository_path": "/home/user/my-project",
  "analysis_date": "2024-11-24T10:30:45.123456",
  "history": {
    "total_commits": 1247,
    "first_commit_date": "2021-03-15T09:23:11+00:00",
    "last_commit_date": "2024-11-24T08:45:32+00:00",
    "total_authors": 23,
    "daily_avg_commits": 0.93,
    "weekly_avg_commits": 6.51,
    "monthly_avg_commits": 27.9,
    "longest_inactive_days": 45,
    "total_lines_added": 156234,
    "total_lines_deleted": 89102
  },
  "risk_files": [
    {
      "path": "src/core/engine.py",
      "risk_score": 87.3,
      "change_frequency": 156,
      "total_lines_changed": 12450,
      "author_count": 8,
      "risk_factors": ["High change frequency", "Many contributors"]
    }
  ],
  "contributors": [
    {
      "name": "Alice Johnson",
      "email": "alice@example.com",
      "commit_count": 312,
      "lines_added": 45234,
      "lines_deleted": 12456,
      "expertise_areas": ["src/core", "src/api"]
    }
  ],
  "commit_patterns": [
    {"keyword": "fix", "count": 312, "percentage": 25.0},
    {"keyword": "feat", "count": 198, "percentage": 15.9}
  ],
  "llm_summary": "# Repository Analysis Summary..."
}

Real-World Scenarios

Scenario 1: Onboarding to a New Project

# Quick overview of project health
gitsum summarize ~/new-project --style executive

# Identify key contributors to reach out to
gitsum summarize ~/new-project --style technical --no-llm

Scenario 2: Code Review Prioritization

# Find riskiest files that need extra review attention
gitsum summarize . --json risks.json --no-llm

# Process with jq
cat risks.json | jq '.risk_files[:5]'

Scenario 3: Sprint Planning

# Analyze recent activity
gitsum summarize . --limit-commits 100 --style technical

Scenario 4: Team Health Check

# Full team analysis
gitsum summarize . --style comprehensive

Tips and Tricks

1. Speed Up Analysis

# Limit commits for faster results
gitsum summarize . --limit-commits 500 --no-llm

2. Integrate with CI/CD

#!/bin/bash
# In your CI pipeline
gitsum summarize . --json analysis.json --no-llm

# Check bus factor
BUS_FACTOR=$(cat analysis.json | jq '.contributors | length')
if [ $BUS_FACTOR -lt 3 ]; then
    echo "⚠️ Warning: Low bus factor detected!"
fi

3. Compare Repositories

# Analyze multiple repos
for repo in ~/projects/*/; do
    echo "=== $repo ==="
    gitsum summarize "$repo" --limit-commits 100 --no-llm
done

Need Help?