feat: add multi-token support for fine-grained PATs#11
Conversation
Add REVIEW_ROADMAP_GITHUB_TOKENS environment variable that accepts a comma-separated list of GitHub tokens. When --post is used, each token is tested for write access until one with the correct permissions is found. This is useful when working with multiple repositories that each have their own fine-grained PAT, eliminating the need to change .env when switching between projects. Changes: - config.py: Add REVIEW_ROADMAP_GITHUB_TOKENS setting with helper methods - client.py: Add find_working_token() function to search for working token - main.py: Use multi-token search when --post flag is provided - env.example: Document new environment variable - tests: Add comprehensive tests for new functionality
The CI environment sets GITHUB_TOKEN as an env var, which pydantic-settings picks up even with _env_file=None. Use monkeypatch.delenv() to ensure tests are isolated from any environment variables.
|
🗺️ Auto-Generated Review Roadmap
Review Roadmap: Multi-Token Support for Fine-Grained PATsHigh-Level SummaryThis PR introduces the ability to configure multiple GitHub Personal Access Tokens (PATs) via a new The change touches configuration, the GitHub client layer, and CLI orchestration, with comprehensive test coverage. Recommended Review Order1. Configuration Layer (Start Here)Why first: Understanding the token management API is foundational—everything else depends on it.
2. GitHub Client AdditionsWhy second: Contains the
3. CLI IntegrationWhy third: See how the pieces are wired together in the user-facing command.
4. Test Suite (Validation Pass)Why last: Confirm edge cases are covered and assertions match expected behavior.
Watch OutsSecurity & Credential Handling
Logic & Edge Cases
API & Rate Limiting
Test Coverage
Existing DiscussionsNo comments have been posted on this PR yet. You're the first reviewer! 🎉 Quick Checklist for Your Review
|
Summary
Add
REVIEW_ROADMAP_GITHUB_TOKENSenvironment variable that accepts a comma-separated list of GitHub tokens. When--postis used, each token is tested for write access until one with the correct permissions is found.This is useful when working with multiple repositories that each have their own fine-grained PAT, eliminating the need to change
.envwhen switching between projects.Changes
REVIEW_ROADMAP_GITHUB_TOKENSsetting with helper methods (get_github_tokens(),get_default_github_token())find_working_token()function to search through tokens for write access--postflag is providedUsage
# In .env - list multiple fine-grained PATs REVIEW_ROADMAP_GITHUB_TOKENS=ghp_token_for_repo1,ghp_token_for_repo2,ghp_token_for_repo3When running with
--post, tokens are tried in order until one with write access is found:Precedence
REVIEW_ROADMAP_GITHUB_TOKENStakes precedence overGITHUB_TOKENfor write operationsGITHUB_TOKENis appended as a fallback if not already in the listTest Results
All 89 tests pass with 84% coverage.