Skip to content

Instantly share code, notes, and snippets.

@cgoldberg
Created October 28, 2025 13:27
Show Gist options
  • Save cgoldberg/aaef78c75f15be247f0b18331b3d152c to your computer and use it in GitHub Desktop.
Save cgoldberg/aaef78c75f15be247f0b18331b3d152c to your computer and use it in GitHub Desktop.
Show GitHub Pull Requests in owner/repo created in the current year
#!/usr/bin/env bash
#
# Show GitHub Pull Requests in owner/repo created in the current year
#
# usage: current_year_prs.sh <owner> <repo>
#
# requires: jq
set -o pipefail
owner="$1"
repo="$2"
pr_url="https://api.github.com/repos/${owner}/${repo}/pulls"
params="state=all&page=2&per_page=100"
pages="20" # number of pages to search
year="$(date +%Y)"
if [ -z "${owner}" ] || [ -z "${repo}" ]; then
echo -e "fatal: missing owner/repo\n"
echo -e "usage:\n current_year_prs.sh <owner> <repo>"
exit 1
fi
lines=""
for page_num in $(seq 1 "${pages}"); do
lines+=$(
curl -sSL \
-H "X-GitHub-Api-Version: 2022-11-28" \
"${pr_url}?state=all&page=${page_num}&per_page=100" \
| jq -r '.[] | "\(.created_at) \(.title)"' \
| grep "${year}-[0-9][0-9]-[0-9][0-9]"
)
done
num_prs=$(wc -l <<< "${lines}")
echo -e "Found ${num_prs} Pull Requests in ${year}:\n"
echo "${lines}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment