Skip to content

Instantly share code, notes, and snippets.

@colin-nolan
Created June 25, 2018 11:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colin-nolan/5bc93b30eaddead69a042a9c08ce7894 to your computer and use it in GitHub Desktop.
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
#!/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