Last active
August 4, 2025 14:14
-
-
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
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
#!/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