Skip to content

Instantly share code, notes, and snippets.

@nperez0111
Last active August 4, 2025 14:14
Show Gist options
  • Save nperez0111/9f31c2f00cbe20bdfce329817e179fea to your computer and use it in GitHub Desktop.
Save nperez0111/9f31c2f00cbe20bdfce329817e179fea to your computer and use it in GitHub Desktop.
A script which can filter PRs that have been made by contributors in a GH repo. Based on: https://bsky.app/profile/ellie.wtf/post/3lvla66gx6c2a
#!/bin/bash
# Minimal GitHub CLI script to get open PRs from previous contributors
set -e
# Get repo from current directory
REPO=$(gh repo view --json nameWithOwner -q .nameWithOwner)
if [ -z "$REPO" ]; then
echo "Error: Not in a git repository."
exit 1
fi
echo "🔍 Analyzing $REPO for open PRs from previous contributors..."
# Get contributors and PRs in one go
CONTRIBUTORS=$(gh api "repos/$REPO/contributors" --paginate --jq '.[].login' | sort -u)
PRS=$(gh pr list --state open --limit 100 --json author,number,title,url)
# Filter PRs by contributors and display
echo "$PRS" | jq -r '
group_by(.author.login) |
sort_by(length) | reverse |
.[] |
"@" + .[0].author.login + " (" + (length | tostring) + " PRs):" +
(.[] | "\n #" + (.number | tostring) + " " + .title + "\n " + .url + "\n Created: " + .createdAt)
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment