-
-
Save yairmark/66cb7da65dccafded4ace8e0da9f602b to your computer and use it in GitHub Desktop.
su GitHub (downloading all repositories from a given user)
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
#!/bin/bash | |
if [ -z "$1" ]; then | |
echo "waiting for the following arguments: username + max-page-number" | |
exit 1 | |
else | |
name=$1 | |
fi | |
if [ -z "$2" ]; then | |
max=2 | |
else | |
max=$2 | |
fi | |
cntx="users" | |
page=1 | |
echo $name | |
# max per page is 100, therefor max number of pages is `ceiling(numberOfRepos/100)` | |
echo $max | |
echo $cntx | |
echo $page | |
echo $GITHUB_API_TOKEN | |
until (( $page -lt $max )) | |
do | |
curl "https://api.github.com/$cntx/$name/repos?page=$page&access_token=$GITHUB_API_TOKEN&per_page=100" | grep -e 'git_url*' | cut -d \" -f 4 | xargs -L1 git clone | |
$page=$page+1 | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment