Last active
March 5, 2018 15:57
-
-
Save mwhitis/864f7a7c386b78ef20227324c120f181 to your computer and use it in GitHub Desktop.
Clone All Repos In an Org - Simple/Naive way to clone all repos in an org on a windows box
This file contains 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
@setlocal | |
set GIT_BASE_URL = https://github.com | |
python getreponames.py %1> allrepos.txt | |
for /f %%a in (allrepos.txt) do ( | |
git clone %GIT_BASE_URL/%1/%%a | |
) |
This file contains 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
import requests | |
import json | |
import sys | |
if len(sys.argv) < 2: | |
print("Usage") | |
sys.exit() | |
org = sys.argv[1] | |
AUTH_TOKEN = # %%%YOUR_AUTH_TOKEN%%% | |
API_BASE_URL = # %%%YOUR_API_BASE_URL%%% EX: https://github.com/api/v3/orgs/ | |
def getreposfororg(org, orgApiUrl, token, per_page = "200"): | |
headers = {'Authorization': token} | |
r = requests.get( orgApiUrl + org + '/repos?per_page=' + per_page, headers=headers) | |
return r.json() | |
unsorted_results = getreposfororg(org, API_BASE_URL, AUTH_TOKEN) | |
print(unsorted_results) | |
results = sorted(unsorted_results, key=lambda r: r['name'].lower()) | |
for repo in results: | |
print(repo['name']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment