This feature allows you to generate Excel reports containing branch information from GitHub repositories.
The generated Excel report includes:
- Branch Name: Name of each branch in the repository
- PR Status: Status of associated pull requests (merged, open, closed, or none)
- Created By: Username of the person who created the branch
- PR URL: Link to the associated pull request (if any)
- Protected: Whether the branch is protected
- Last Commit Date: Date and time of the last commit on the branch
-
Install required dependencies:
pip install -r requirements.txt
-
Set up GitHub authentication (required for accessing private repositories and higher rate limits):
export GITHUB_TOKEN='your_github_personal_access_token'
To create a GitHub personal access token:
- Go to GitHub Settings → Developer settings → Personal access tokens
- Generate a new token with
reposcope for private repositories - For public repositories only, the token is optional but recommended to avoid rate limits
Use the FastAPI endpoint to generate reports:
GET /api/v4/generate_branch_report?owner=<owner>&repo=<repo>Parameters:
owner(required): Repository owner (username or organization)repo(required): Repository name
Example:
curl -X GET "http://localhost:8000/api/v4/generate_branch_report?owner=microsoft&repo=Multi-Agent-Custom-Automation-Engine-Solution-Accelerator" \
-H "user_principal_id: your-user-id" \
-o branch_report.xlsxRun the standalone script directly:
cd src/backend
python generate_branch_report.py <owner> <repo> [output_file]Examples:
# Generate report with default filename
python generate_branch_report.py microsoft Multi-Agent-Custom-Automation-Engine-Solution-Accelerator
# Generate report with custom filename
python generate_branch_report.py microsoft Multi-Agent-Custom-Automation-Engine-Solution-Accelerator my_report.xlsxThe Excel file contains:
- Professional formatting with styled headers
- Color-coded rows for easy reading
- Auto-sized columns for optimal viewing
- Clickable PR URLs (when applicable)
If you encounter rate limiting errors:
- Set the
GITHUB_TOKENenvironment variable with a valid token - Authenticated requests have a limit of 5,000 requests per hour
- Unauthenticated requests are limited to 60 per hour
If you cannot access a repository:
- Ensure the repository is public, or your token has access to private repositories
- Verify the owner and repository names are correct
- Check that your token has the necessary scopes (
repofor private repos)
If the report is empty:
- Verify the repository exists and has branches
- Check the console logs for specific error messages
- Ensure network connectivity to GitHub API
GitHub API has the following rate limits:
- Authenticated: 5,000 requests per hour
- Unauthenticated: 60 requests per hour
Each repository typically requires:
- 1 request to fetch the repository
- 1 request per branch to get details
- 1 request per branch to check for pull requests
For large repositories, consider using authentication to avoid rate limits.
- Never commit your
GITHUB_TOKENto version control - Use environment variables or secure secret management
- Tokens should have minimal required permissions
- Regularly rotate your tokens for security
You can test the GitHub Excel Generator utility:
from common.utils.github_excel_generator import GitHubExcelGenerator
# Initialize with token
generator = GitHubExcelGenerator(github_token="your_token")
# Generate report
success = generator.generate_report("microsoft", "Multi-Agent-Custom-Automation-Engine-Solution-Accelerator", "output.xlsx")To add more columns to the report, modify:
github_excel_generator.py: Updateget_branch_info()to collect additional datagithub_excel_generator.py: Updategenerate_excel()to include new columns in the spreadsheet
For issues or questions:
- Check the application logs for detailed error messages
- Review GitHub API status at https://www.githubstatus.com/
- Ensure all prerequisites are properly configured