|
1 | 1 | import os, requests, base64, re, time, urllib |
2 | | -from . import gx_definitions, gx_output |
3 | 2 |
|
4 | 3 | # GitHub API URL |
5 | 4 | GITHUB_API_BASE_URL = "https://api.github.com" |
@@ -83,7 +82,7 @@ def github_request_json(url, params=None, limit_results=None): |
83 | 82 | message = f"GitHub Rate limit reached. Sleeping for {hours} hours, {minutes} minutes, and {seconds} seconds. You may go and make coffee.." |
84 | 83 | print(f"\r\n\033[33m{message}\033[0m", flush=True) |
85 | 84 | if GITHUB_TOKEN == None: |
86 | | - message = f"You should try using a Github Access Token, improves the experience significantly and it's easy!" |
| 85 | + message = f"You should try using a GitHub Access Token, improves the experience significantly and it's easy!" |
87 | 86 | print(f"\033[33m{message}\033[0m", flush=True) |
88 | 87 | print("For information on how to create a GitHub API Access Token refer to: ") |
89 | 88 | print("https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens") |
@@ -218,7 +217,14 @@ def fetch_repository_branches(repo): |
218 | 217 | return github_request_json(f"{GITHUB_API_BASE_URL}/repos/{repo.get('full_name')}/branches") |
219 | 218 |
|
220 | 219 | def fetch_repository_contributors(repo): |
221 | | - return github_request_json(repo.get('contributors_url'), {'anon':1}) |
| 220 | + data = github_request_json(repo.get('contributors_url'), {'anon':1}) |
| 221 | + # Disregarding if anon is set to 1/True or not, in extremely large repositories, GH returns a 403 status with: |
| 222 | + # "The history or contributor list is too large to list contributors for this repository via the API." |
| 223 | + if isinstance(data, dict) and data.get("status", "0") == "403": |
| 224 | + print(f"\r\n\033[33mGitHub's REST API declined returning the list of Contributors with a message:\033[0m", flush=True) |
| 225 | + print(f"\033[33m{data.get('message','')}\033[0m", flush=True) |
| 226 | + return {} |
| 227 | + return data |
222 | 228 |
|
223 | 229 | def fetch_repository_deployments(repo): |
224 | 230 | return github_request_json(repo.get('deployments_url')) |
|
0 commit comments