Skip to content

Instantly share code, notes, and snippets.

@y16ra
Last active May 8, 2025 01:54
Show Gist options
  • Save y16ra/8f3f2a7e4baeceba29bfec1eba4fdc53 to your computer and use it in GitHub Desktop.
Save y16ra/8f3f2a7e4baeceba29bfec1eba4fdc53 to your computer and use it in GitHub Desktop.
This one-liner fetches the commit headlines for a pull request, filters lines that contain "Merge pull request", and then extracts only the PR numbers (e.g., #10) from those lines.
gh pr view 1 --json commits --jq '.commits[].messageHeadline' | grep "Merge pull request" | grep -o '#[0-9]\+'
@y16ra
Copy link
Author

y16ra commented May 8, 2025

PR取得順ではなく、PRの番号順に並べ替える場合

gh pr view 1 --json commits --jq '.commits[].messageHeadline' \
| grep "Merge pull request" \
| grep -o '#[0-9]\+' \
| sed 's/#//' \
| sort -n \
| sed 's/^/#/'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment