Last active
December 22, 2024 21:10
-
-
Save satorg/9636a084aec855f21543175e4c361196 to your computer and use it in GitHub Desktop.
This file contains 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 zsh | |
set -eu | |
readonly base_branch=main | |
readonly start_from_commit=v2.12.0 | |
readonly steward_name=typelevel-steward | |
readonly start_from_datetime=$(git show "$start_from_commit" --format=%cI) | |
readonly merged_prs_jq='map(" - #\(.number) by @\(.author.login)")' | |
readonly update_prs_jq='sort_by(.title) | map(" - #\(.number)")' | |
readonly mergeable_prs_jq=' | |
map( | |
select(.mergeable == "MERGEABLE") | | |
{ | |
number, | |
author: .author.login, | |
approvedStr: .reviews | | |
map( | |
select(.state == "APPROVED" and .authorAssociation == "MEMBER") | | |
.author.login | |
) | | |
unique | | |
map("@\(.)") | | |
join(", ") | | |
"approved by \(.)" | |
} | | |
" - #\(.number) by @\(.author) (\(.approvedStr))" | |
) | |
' | |
readonly unmergeable_prs_jq=' | |
map( | |
select(.mergeable != "MERGEABLE") | | |
{ | |
number, | |
author: .author.login, | |
approvedStr: .reviews | | |
map( | |
select(.state == "APPROVED" and .authorAssociation == "MEMBER") | | |
.author.login | |
) | | |
unique | | |
map("@\(.)") | | |
join(", ") | | |
"approved by \(.)" | |
} | | |
" - #\(.number) by @\(.author) (\(.approvedStr))" | |
) | |
' | |
# shellcheck disable=SC2016 | |
readonly ready_prs_jq=' | |
map( | |
select(.mergeable == "MERGEABLE") | | |
.author.login as $author | | |
{ | |
number, | |
author: $author, | |
reviewedStr: (.reviews + .comments) | | |
map( | |
select(.author.login != $author and .authorAssociation == "MEMBER") | | |
.author.login | |
) | | |
if isempty(.[]) then | |
"no reviews" | |
else | |
unique | | |
map("@\(.)") | | |
join(", ") | | |
"reviewed by \(.)" | |
end | |
} | | |
" - #\(.number) by @\(.author) (\(.reviewedStr))" | |
) | |
' | |
print " | |
## Merged | |
All PRs merged after the $start_from_commit release. | |
### Contributions | |
All PRs created by contributors. | |
<details> | |
" | |
gh pr list \ | |
--base "$base_branch" \ | |
--search "sort:created-asc is:pr merged:>$start_from_datetime -author:app/$steward_name" \ | |
--json number,author,title \ | |
--jq "$merged_prs_jq" \ | |
--limit 1000 | | |
jq -r '.[]' | |
print " | |
</details> | |
### Updates | |
All updates by @$steward_name. | |
<details> | |
" | |
gh pr list \ | |
--base "$base_branch" \ | |
--search "merged:>$start_from_datetime author:app/$steward_name" \ | |
--json number,author,title \ | |
--jq "$update_prs_jq" \ | |
--limit 1000 | \ | |
jq -r '.[]' | |
print " | |
</details> | |
## Approved | |
Reviewed PRs that have got at least 1 approval from the organization members. | |
### Ready to be merged | |
These PRs have no conflicts and expected to be merged soon unless concerns or objections emerge. Additional reviews and approvals are very welcome but not required for these PRs to get them merged. | |
" | |
gh pr list \ | |
--base "$base_branch" \ | |
--search 'sort:created-asc is:pr is:open draft:false status:success review:approved' \ | |
--json number,author,title,mergeable,reviews \ | |
--jq "$mergeable_prs_jq" \ | |
--limit 1000 | | |
jq -r '.[]' | |
print " | |
### Approved, but got conflicts | |
These PRs have got some conflicts due to recent merges. Therefore they can be merged once the conflicts are resolved. | |
" | |
gh pr list \ | |
--base "$base_branch" \ | |
--search 'sort:created-asc is:pr is:open draft:false status:success review:approved' \ | |
--json number,author,title,mergeable,reviews \ | |
--jq "$unmergeable_prs_jq" \ | |
--limit 1000 | | |
jq -r '.[]' | |
print " | |
## Ready for Review | |
PRs that look pretty complete but either haven't been reviewed or approved, or may need some additional work on the comments to get their approvals. | |
" | |
gh pr list \ | |
--base "$base_branch" \ | |
--search "sort:created-asc is:pr is:open draft:false status:success review:required" \ | |
--json number,author,title,mergeable,reviews,comments \ | |
--jq "$ready_prs_jq" \ | |
--limit 1000 | | |
jq -r '.[]' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment