Created
June 12, 2021 07:17
-
-
Save ilammy/6e0141029b87e51c58ef65095716f7e6 to your computer and use it in GitHub Desktop.
Scanning GitHub for repos with Pollen files in them
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
#!/usr/bin/env bash | |
# | |
# Scan GitHub for repositories with Pollen files. | |
# | |
# Environment variables: | |
# | |
# GITHUB_USER GitHub username | |
# GITHUB_TOKEN Personal access token on GitHub with "public_repo" scope | |
set -ueo pipefail | |
matching_repos() { | |
local query="$1" | |
# GitHub search API returns up to 1000 resuls. | |
for page in $(seq 1 10) | |
do | |
curl --silent \ | |
-H "accept: application/vnd.github.v3+json" \ | |
-u "$GITHUB_USER:$GITHUB_TOKEN" \ | |
"https://api.github.com/search/code?q=$query&per_page=100&page=$page" \ | |
| jq -r "[.items[].repository.full_name] | .[]" | |
echo -n >&2 "." | |
# Search API has rate-limit of 30 authenticated requests per minute. | |
sleep 3 | |
done | |
echo >&2 | |
} | |
( | |
matching_repos "lang+pollen+extension:ptree" | |
matching_repos "lang+pollen+extension:pm" | |
matching_repos "lang+pollen+extension:pp" | |
matching_repos "lang+pollen+extension:p" | |
) | sort -u |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment