Created
March 9, 2025 04:54
-
-
Save Ryex/35ab55821365abcc7b57ea2f621b4a76 to your computer and use it in GitHub Desktop.
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
REPO="Prismlauncher" | |
OWNER="Prismlauncher" | |
PRS=$( | |
gh api graphql -f query=' | |
query($repo: String!, $owner: String!, $endCursor: String) { | |
repository(name: $repo, owner: $owner) { | |
pullRequests(first: 100, after: $endCursor, states: [OPEN], labels: ["blocked"]) { | |
nodes { | |
number | |
bodyText | |
isDraft | |
headRef { | |
target { | |
oid | |
} | |
repository { | |
owner { | |
login | |
} | |
url | |
} | |
} | |
isCrossRepository | |
} | |
pageInfo { | |
hasNextPage | |
endCursor | |
} | |
} | |
} | |
} | |
' \ | |
-f repo=$REPO \ | |
-f owner=$OWNER \ | |
--paginate \ | |
--jq '.data.repository.pullRequests.nodes[]' \ | |
| jq -s \ | |
| jq 'map( | |
select(.isDraft == false) | |
| . as $obj | |
| ( | |
$obj.bodyText | scan("blocked by:? #(?<num>[0-9]+)") | map(tonumber) | |
) as $prs | |
| . + {"blockingPRs" : $prs} | |
| del(.bodyText) | |
)' | |
) | |
while read pr ; do | |
num=$(echo $pr | jq '.number') | |
headRef="$(echo $pr | jq -r '.headRef.repository.owner.login'):$(echo $pr | jq -r '.headRef.target.oid')" | |
while read blockingPR ; do | |
base=$( | |
gh api graphql -f repo=$REPO -f owner=$OWNER -F pr=$blockingPR -f query=' | |
query($repo: String!, $owner: String!, $pr: Int!) { | |
repository(name: $repo, owner: $owner) { | |
pullRequest(number: $pr) { | |
merged | |
headRef { | |
target { | |
oid | |
} | |
repository { | |
owner { | |
login | |
} | |
url | |
} | |
} | |
} | |
} | |
} | |
' \ | |
--jq '.data.repository.pullRequest' | |
) | |
repoOwner=$(echo $base | jq -r '.headRef.repository.owner.login') | |
repoUrl=$(echo $base | jq -r '.headRef.repository.url') | |
baseRef=$(echo $base | jq -r '.headRef.target.oid') | |
echo "$repoUrl/compare/$baseRef...$headRef | $(echo $base | jq -r '.merged');" | |
done < <(echo $pr | jq -c '.blockingPRs[]') | |
done < <(echo $PRS | jq -c '.[]') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment