Skip to content

abdianrizky/github-pr-tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub PR Activity Tracker

A powerful command-line tool for comprehensive GitHub Pull Request activity tracking and analysis. Monitor and visualize your contribution patterns across multiple repositories.

Features

  • 📊 Multi-repository PR data retrieval and analysis
  • 📈 Detailed PR creation and review statistics
  • 📅 Flexible date range filtering
  • 📊 Monthly activity breakdown
  • 📉 ASCII chart visualization of PR trends
  • 💾 Data export in multiple formats (JSON, CSV, Excel)
  • 🔐 GitHub OAuth authentication support

Installation

  1. Ensure you have Go 1.19 or later installed
  2. Clone the repository:
git clone https://github.com/adonism2k/gh-pr-tracker
cd gh-pr-tracker
  1. Install dependencies:
make install
  1. Build the binary:
make build

Configuration

  1. Copy the example environment file:
cp .env.example .env
  1. Configure your environment variables in .env:
# Option 1: Using Personal Access Token (Classic)
GITHUB_TOKEN=your_github_token_here

# Option 2: Using OAuth (recommended)
GITHUB_CLIENT_ID=your_client_id_here
GITHUB_CLIENT_SECRET=your_client_secret_here

# Default settings
DEFAULT_REPOSITORY=owner/repo
DEFAULT_START_DATE=2025-01-01
DEFAULT_END_DATE=2025-02-22

Authentication Options

Option 1: Personal Access Token

To create a GitHub token:

  1. Go to GitHub Settings > Developer Settings > Personal Access Tokens > Tokens (classic)
  2. Generate a new token with 'repo' scope access
  3. Copy the token to your .env file as GITHUB_TOKEN

Option 2: GitHub OAuth (Recommended)

For a more secure authentication experience:

  1. View OAuth setup instructions:
make setup-oauth
  1. Go to GitHub Settings > Developer Settings > OAuth Apps > New OAuth App
  2. Fill in the application details:
    • Application name: GitHub PR Tracker
    • Homepage URL: http://localhost:4000
    • Authorization callback URL: http://localhost:4000/callback
  3. After creating the app, you'll receive a Client ID and can generate a Client Secret
  4. Add these credentials to your .env file:
    GITHUB_CLIENT_ID=your_client_id_here
    GITHUB_CLIENT_SECRET=your_client_secret_here

When running the application without a GITHUB_TOKEN, it will automatically:

  1. Start a local server for OAuth callback
  2. Open your browser for GitHub authentication
  3. Handle the OAuth flow securely
  4. Store and use the received token for API access

Usage

Fetch PR Activity Data

# Using default repository and date range from .env
./gh-pr-tracker fetch

# Specify repository and date range
./gh-pr-tracker fetch --repo=owner/repo --start=2025-01-01 --end=2025-02-22

# Multiple repositories
./gh-pr-tracker fetch --repo=owner/repo1,owner/repo2 --start=2025-01-01 --end=2025-02-22

Generate Activity Chart

# Using default repository and date range
./gh-pr-tracker chart

# Custom repository and date range
./gh-pr-tracker chart --repo=owner/repo --start=2025-01-01 --end=2025-02-22

Export Data

Export PR data in various formats:

# Export to JSON (default)
./gh-pr-tracker export --format=json --output=pr_data.json

# Export to CSV
./gh-pr-tracker export --format=csv --output=pr_data.csv

# Export to Excel
./gh-pr-tracker export --format=xlsx --output=pr_data.xlsx

Using Makefile Commands

# Build the application
make build

# Fetch PR data
make fetch REPO=owner/repo START_DATE=2025-01-01 END_DATE=2025-02-22

# Generate chart
make chart REPO=owner/repo START_DATE=2025-01-01 END_DATE=2025-02-22

# Export data in different formats
make export REPO=owner/repo START_DATE=2025-01-01 END_DATE=2025-02-22
make export-csv REPO=owner/repo START_DATE=2025-01-01 END_DATE=2025-02-22
make export-excel REPO=owner/repo START_DATE=2025-01-01 END_DATE=2025-02-22

# View OAuth setup instructions
make setup-oauth

Example Output

PR Activity Summary

Your PR Activity Summary:
✓ Total PRs Created: 21
✓ Reviews Made: 1
✓ Open PRs: 1
✓ Closed PRs: 20
✓ Average PRs per month: 10.50
✓ Reviews/PRs Ratio: 0.05

Activity Chart

 14.00 ┼─╮
 13.53 ┤ ╰───╮
 12.60 ┤     ╰───╮
 11.67 ┤         ╰───╮
 10.73 ┤             ╰───╮
  9.80 ┤                 ╰───╮
  8.87 ┤                     ╰───╮
  7.93 ┤                         ╰───╮
  7.00 ┤                             ╰─

Monthly Breakdown:
• 2025-01 (14 PRs)
• 2025-02 (7 PRs)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors