Created
June 25, 2018 11:37
-
-
Save colin-nolan/5bc93b30eaddead69a042a9c08ce7894 to your computer and use it in GitHub Desktop.
Gets a list of GitHub repositories that a user has contributed to within the last 90 days
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
#!/usr/bin/env bash | |
# | |
# Note: there is a 300 event/90 day limit (https://developer.github.com/v3/activity/events/). | |
# | |
# Requires: jq curl sed grep | |
# | |
set -euf -o pipefail | |
GIT_USER=$1 | |
MAX_PAGES=$(curl -I -s https://api.github.com/users/${GIT_USER}/events | grep ^Link | sed 's/.*page=\([0-9]\+\).*/\1/') \ | |
|| curl -I https://api.github.com/users/${GIT_USER}/events | |
for i in $(seq 1 ${MAX_PAGES}); do | |
curl -s https://api.github.com/users/${GIT_USER}/events?page=$i \ | |
| jq -r '.[] | select(.type=="PushEvent") | .repo.name' \ | |
|| curl https://api.github.com/users/${GIT_USER}/events?page=$i | |
done \ | |
| sort -u |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment