(explicit_token: str | None)
| 227 | |
| 228 | |
| 229 | def load_token(explicit_token: str | None) -> str | None: |
| 230 | if explicit_token: |
| 231 | return explicit_token |
| 232 | for env_name in ('GITHUB_API_TOKEN', 'GITHUB_TOKEN', 'GH_TOKEN'): |
| 233 | value = os.getenv(env_name) |
| 234 | if value: |
| 235 | return value |
| 236 | token_file = Path('~/.gh_tokenrc').expanduser() |
| 237 | if token_file.exists(): |
| 238 | match = re.search(r'github_oauth\s*=\s*(\S+)', token_file.read_text()) |
| 239 | if match: |
| 240 | return match.group(1) |
| 241 | return None |
| 242 | |
| 243 | |
| 244 | def collect_commits( |