A Python application that analyzes and visualizes daily merge counts for GitHub repositories over the past month.
- Fetch daily merge counts from any public GitHub repository
- Generate interactive graphs using matplotlib
- Command-line interface for easy integration
- Support for various GitHub URL formats
- Customizable time periods for analysis
- Rate limiting and error handling
Here's an example of the daily merge count visualization generated by the tool:
Example: Daily merge count analysis for nakanoh/github-merge-analytics over the past 30 days
The graph shows:
- Total: 1 merge
- Average: 0.0 merges per day
- Peak: 1 merge (maximum in a single day)
- Python 3.8+
- Internet connection for GitHub API access
- Clone this repository:
git clone https://github.com/nakanoh/github-merge-analytics.git
cd github-merge-analytics- Install dependencies:
pip install -r requirements.txtTo increase API rate limits from 60 to 5000 requests/hour, set up a GitHub Personal Access Token:
-
Create a Personal Access Token:
- Go to GitHub Settings → Developer settings → Personal access tokens → Tokens (classic)
- Click "Generate new token (classic)"
- Select scopes: Only
public_repois needed for public repositories - Copy the generated token
-
Set the environment variable:
export GITHUB_TOKEN=ghp_your_token_here- Run the application as normal:
python main.py --repo https://github.com/owner/repoThe application will automatically detect and use the token for authentication.
Analyze a repository for the past 30 days:
python main.py --repo https://github.com/owner/repoThe tool supports various GitHub URL formats:
# HTTPS URL
python main.py --repo https://github.com/microsoft/vscode
# SSH URL format
python main.py --repo git@github.com:microsoft/vscode.git
# Short format
python main.py --repo microsoft/vscodeAnalyze for a different number of days:
python main.py --repo https://github.com/owner/repo --days 60--repo(required): GitHub repository URL or owner/repo format--days(optional): Number of days to analyze (default: 30)
The application will:
- Display analysis progress in the terminal
- Show statistics about the repository's merge activity
- Generate and display a graph with:
- Daily merge counts over the specified period
- Total merges, average per day, and peak activity
- Date formatting for easy reading
python main.py --repo https://github.com/facebook/reactpython main.py --repo microsoft/typescript --days 14The generated graph includes:
- Line plot with markers showing daily merge activity
- Grid lines for better readability
- Rotated date labels to prevent overlap
- Summary statistics at the bottom
- Professional styling with proper titles and labels
The application handles GitHub API rate limiting:
- Uses appropriate User-Agent headers
- Provides clear error messages if rate limits are exceeded
- Supports GitHub Personal Access Token authentication for 5000 requests/hour (vs 60 for unauthenticated)
- Automatically detects and uses
GITHUB_TOKENenvironment variable - Falls back gracefully to unauthenticated requests if no token is provided
The application includes comprehensive error handling for:
- Invalid repository URLs
- Network connectivity issues
- GitHub API errors
- Invalid command line arguments
requests: HTTP library for GitHub API callsmatplotlib: Plotting library for graph generation
- Uses GitHub REST API v3
- Fetches closed pull requests with merge information
- Processes merge timestamps for daily aggregation
- Filters pull requests by merge date
- Aggregates data into daily counts
- Handles timezone conversions appropriately
- Only works with public repositories
- Subject to GitHub API rate limits (60 requests/hour without token, 5000 with token)
- Requires graphical display for matplotlib output
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is open source. Please check the repository for license details.
"Rate limit exceeded":
- Set up a GitHub Personal Access Token (see GitHub Authentication section above)
- Or wait for the rate limit to reset (typically 60 minutes for unauthenticated requests)
"Invalid GitHub repository URL":
- Ensure the URL is correctly formatted
- Try the short format:
owner/repo
Graph not displaying:
- Ensure you have a graphical environment
- Check that matplotlib is properly installed
No data found:
- Verify the repository has merged pull requests in the specified time period
- Check that the repository exists and is public
If you encounter issues:
- Check the troubleshooting section above
- Verify your Python and dependency versions
- Open an issue in the GitHub repository with detailed error information