Skip to content

Instantly share code, notes, and snippets.

@scotchneat
Last active November 1, 2023 16:24
Show Gist options
  • Save scotchneat/77ff5609cee9ae8d66f28fdeba8ecd5e to your computer and use it in GitHub Desktop.
Save scotchneat/77ff5609cee9ae8d66f28fdeba8ecd5e to your computer and use it in GitHub Desktop.
GitHub [gh] list all merged PRs since last commit to master
set -e
repo=coreweave/cloud-app
git checkout develop
# Get Current commit
latest_sha=$(git rev-parse --short master)
# Get date for current commit
latest_sha_date=$(gh pr list -s merged --json number,title,mergedAt,labels,mergeCommit,baseRefName,headRefName --repo $repo | jq -r --arg sha "$latest_sha" '.[] | select(.mergeCommit.oid | startswith($sha)) | .mergedAt')
echo "Current SHA: $latest_sha ($latest_sha_date)"
# List PRs for release
gh pr list --repo $repo -s merged --json number,title,mergedAt,commits,labels \
--jq '[. | sort_by(.mergedAt) | .[] | {"number": .number, "title": .title, "mergedAt": .mergedAt, "contributors": ([.commits[].authors[] | "@" + .login] | unique | join(", ")), "labels": ([.labels[] | .name] | join("|"))} ]' | \
jq --arg prev $latest_sha_date \
'[.[] | select(.mergedAt > $prev)]' | \
jq -r '.[] | select(.labels | contains("ignore-for-changelog") | not) | "* #\(.number): [\(.contributors)]"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment