Skip to main content

Intelligent tool for collecting, analyzing, and summarizing GitHub Pull Requests and commits

Project description

GitHub PR & Commit Analyzer

中文文档 | English

A powerful command-line tool for intelligently collecting, analyzing, and summarizing GitHub Pull Requests and commit records. Supports keyword-based smart search and AI-powered analysis features.

✨ Key Features

  • 🔍 Smart Search: AI-powered keyword extraction and intelligent PR/Commit search
  • 📊 Data Collection: Automatically collect open and merged PRs, as well as merge commits
  • 🔄 Diff Viewing: Complete code change viewing functionality
  • 🤖 AI Analysis: Integrated with cursor-agent CLI for intelligent change summarization
  • 📅 DateTime Display: Comprehensive date/time information for all PRs and commits
  • 💼 Production Quality: Complete error handling, logging, and user experience
  • 🎨 Beautiful Output: Professional terminal output using Rich library
  • ⚙️ Environment Variables: Direct environment variable configuration (no config files needed)

📋 Prerequisites

Before using this tool, ensure the following dependencies are installed:

Required Dependencies

  1. Python 3.8+

    python --version  # should be >= 3.8
    
  2. Git

    git --version
    
  3. GitHub CLI (gh)

    # Ubuntu/Debian
    sudo apt install gh
    
    # macOS
    brew install gh
    
    # Windows
    choco install gh
    

    After installation, you need to login:

    gh auth login
    

Optional Dependencies

  1. cursor-agent CLI (for AI analysis features)
    • If you need AI analysis features, please deploy cursor-agent in advance
    • Configure the path in the .env file

🚀 Installation

Method 1: Install from Source

# Clone or download the project
cd github-pr-analyzer

# Install dependencies
pip install -r requirements.txt

# Or install using setup.py
pip install -e .

Method 2: Using Virtual Environment (Recommended)

# Create virtual environment
python -m venv venv

# Activate virtual environment
# Linux/macOS:
source venv/bin/activate
# Windows:
venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

⚙️ Configuration

Configure the tool using environment variables:

# AI Configuration (Optional)
export CURSOR_AGENT_PATH=/path/to/cursor-agent

# Default Settings (Optional)
export DEFAULT_MONTHS=3
export DEFAULT_REPO_PATH=.

No configuration files needed - just set environment variables directly!

📖 Usage

Basic Commands

1. Collect PRs and Commits

# Auto-detect current repository
python main.py collect

# Specify repository
python main.py collect --repo owner/repo

# Specify time range (months)
python main.py collect --months 6

2. Search for Relevant Changes

# Basic search
python main.py search "bug fix authentication"

# With AI analysis
python main.py search "add new feature" --analyze

# Show diff
python main.py search "optimization" --show-diff

# Advanced options with smart search
python main.py search "refactor" \
  --repo owner/repo \
  --months 6 \
  --min-score 50 \
  --max-results 10 \
  --analyze \
  --smart-search

# Disable smart search (use traditional search)
python main.py search "refactor" --no-smart-search

3. View Specific PR

# View PR details
python main.py view-pr 123

# View PR with AI analysis
python main.py view-pr 123 --analyze

# Specify repository
python main.py view-pr 123 --repo owner/repo

4. View Specific Commit

# View commit details
python main.py view-commit abc1234

# View and analyze
python main.py view-commit abc1234 --analyze

5. Interactive Mode

# Launch interactive interface
python main.py interactive

🎯 Use Cases

Scenario 1: Find All Changes Related to Specific Feature

# Search for all PRs and commits related to "authentication"
python main.py search "authentication" --months 3 --analyze

# Output:
# - List of matching PRs and commits (sorted by relevance)
# - AI-generated summary for each change
# - Option to save analysis report

Scenario 2: Review Recent Merges

# Collect all merges from the last 3 months
python main.py collect --months 3

# Then search for specific types of changes
python main.py search "performance optimization" --show-diff

Scenario 3: Deep Dive into Specific PR

# View complete information for PR #456
python main.py view-pr 456 --analyze

# Output includes:
# - PR basic information
# - Complete diff
# - AI analysis: purpose, impact, technical details

🛠️ Development

Project Structure

github-pr-analyzer/
├── main.py                 # Program entry point
├── setup.py               # Installation configuration
├── requirements.txt       # Dependency list
├── .env.example          # Configuration template
├── .gitignore            # Git ignore rules
├── README.md             # This document
└── src/
    ├── __init__.py
    ├── config.py         # Configuration management
    ├── utils.py          # Utility functions
    ├── pr_collector.py   # PR collection module
    ├── commit_collector.py  # Commit collection module
    ├── diff_viewer.py    # Diff viewing module
    ├── matcher.py        # Smart matching module
    ├── ai_analyzer.py    # AI analysis module
    └── cli.py            # Command-line interface

Running Tests

# Basic functionality test
python main.py --help

# Check dependencies
python test_installation.py

📝 FAQ

Q: Getting "gh CLI not authenticated"

A: Run gh auth login and complete GitHub authentication.

Q: Repository not found

A: Make sure you're in a Git repository directory, or use --repo owner/repo to specify explicitly.

Q: AI analysis not available

A: Configure CURSOR_AGENT_PATH in the .env file. AI features are optional.

Q: Too many/too few search results

A: Adjust the --min-score parameter (lower for more results, higher for more precise results).

🤝 Contributing

Issues and Pull Requests are welcome!

📄 License

This project is licensed under the MIT License - free for commercial and personal use.

Copyright (c) 2025 GitHub PR Analyzer Team

🔗 Related Resources

📧 Contact

For questions or suggestions, please contact us via Issues.


Enjoy analyzing! 🎉

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

github_pr_analyzer-3.0.1.tar.gz (24.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

github_pr_analyzer-3.0.1-py3-none-any.whl (35.4 kB view details)

Uploaded Python 3

File details

Details for the file github_pr_analyzer-3.0.1.tar.gz.

File metadata

  • Download URL: github_pr_analyzer-3.0.1.tar.gz
  • Upload date:
  • Size: 24.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for github_pr_analyzer-3.0.1.tar.gz
Algorithm Hash digest
SHA256 3c92ebb9ddf31aa4d37a70f24f3bc11e61fb13943c6f6117c0b2ceed859a8165
MD5 41e91fd8a0ef6e423cfe9dff8d876cf4
BLAKE2b-256 597d2df7b32ce710d8e3154b15192482da4d9cf9458b48de05580441b5376ac4

See more details on using hashes here.

File details

Details for the file github_pr_analyzer-3.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for github_pr_analyzer-3.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d3ae7ce2cbf0e310fdb1b5833cc305602e89d8eebb458228b5662327dda69ea6
MD5 cfd322cb3addbbd25f3458d4589fad52
BLAKE2b-256 8f3849469ad5e46dacd916a0f39f634314cf989c2e8324583d7509ddfe06241f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page