-
-
Save KyMidd/13b5fb7d320a9859be66c90f6a630975 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Define function | |
| def get_all_repo_names(): | |
| # Check API token wallet | |
| hold_until_rate_limit_success() | |
| repo_count_info = get_repo_count() | |
| # Can get 100 repos at a time, so need to loop over all repos | |
| repos = [] | |
| # Announce | |
| print() | |
| print("Fetching all repos") | |
| per_page=100 | |
| for i in range(1, repo_count_info["TOTAL_REPO_COUNT"]//100+2): | |
| print("Fetching repos page "+str(i)) | |
| # Fetch all repos | |
| response = requests.get( | |
| url="https://api.github.com/orgs/"+GITHUB_ORG+"/repos?per_page="+str(per_page)+"+&page="+str(i), | |
| headers=headers | |
| ) | |
| # Check response code, and if not 200, exit | |
| if response.status_code != 200: | |
| print("Error fetching repos") | |
| exit(1) | |
| # Iterate over response, find all repos | |
| for repo in response.json(): | |
| # If not archived, disabled, or template, append | |
| if repo["archived"] == False and repo["disabled"] == False and repo["is_template"] == False: | |
| repos.append(repo["name"]) | |
| # Announce | |
| print() | |
| return repos | |
| # Get all repo information | |
| repo_names = get_all_repo_names() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment