|
| 1 | +#!/usr/bin/env zsh |
| 2 | + |
| 3 | +# Script to find PRs not mentioned in the changelog |
| 4 | +# |
| 5 | +# Disclaimer: This script was auto-generated by Claude Code. |
| 6 | +# |
| 7 | +# Usage: ./cicd_utils/find-unmentioned-prs.sh |
| 8 | +# |
| 9 | +# Note: Take a look at the `all_prs=($(gh pr list ...))` line to see all the filters used to fetch PRs. |
| 10 | +# |
| 11 | +# Requirements: |
| 12 | +# * GitHub CLI (gh) must be installed and authenticated. |
| 13 | +# * jq must be installed for JSON parsing. |
| 14 | +# * The changelog file must exist at ./docs/reference/changelog.md |
| 15 | +# * The script assumes the main branch is named 'main' |
| 16 | +# * PRs are referenced in the changelog using the pattern {gh-pr}`PR-NUMBER` |
| 17 | +# * The script should be run from the root of the repository |
| 18 | + |
| 19 | +set -e |
| 20 | + |
| 21 | +CHANGELOG_FILE="./docs/reference/changelog.md" |
| 22 | + |
| 23 | +# Check if changelog file exists |
| 24 | +if [[ ! -f "$CHANGELOG_FILE" ]]; then |
| 25 | + echo "Error: Changelog file not found at $CHANGELOG_FILE" |
| 26 | + exit 1 |
| 27 | +fi |
| 28 | + |
| 29 | +# Check if gh CLI is available |
| 30 | +if ! command -v gh &> /dev/null; then |
| 31 | + echo "Error: GitHub CLI (gh) is not installed" |
| 32 | + exit 1 |
| 33 | +fi |
| 34 | + |
| 35 | +echo "🔍 Finding PRs not mentioned in changelog..." |
| 36 | +echo |
| 37 | + |
| 38 | +# Get all PR numbers from GitHub (both open and closed) |
| 39 | +echo "📥 Fetching all PRs from GitHub..." |
| 40 | +all_prs=($(gh pr list --state merged --base main --label 'skip news' --search 'merged:>2025-09-01' --limit 100 --json number --jq '.[].number')) |
| 41 | +if [[ ${#all_prs[@]} -eq 0 ]]; then |
| 42 | + echo "No PRs found in this repository." |
| 43 | + exit 0 |
| 44 | +fi |
| 45 | + |
| 46 | +echo "Found ${#all_prs[@]} total PRs" |
| 47 | + |
| 48 | +# Extract PR numbers mentioned in changelog using the pattern {gh-pr}`PR-NUMBER` |
| 49 | +echo "📖 Parsing changelog for mentioned PRs..." |
| 50 | +mentioned_prs=($(grep -o '{gh-pr}`[0-9]\+`' "$CHANGELOG_FILE" | sed 's/{gh-pr}`\([0-9]\+\)`/\1/' | sort -n | uniq)) |
| 51 | + |
| 52 | +echo "Found ${#mentioned_prs[@]} PRs mentioned in changelog" |
| 53 | +echo |
| 54 | + |
| 55 | +# Find PRs not mentioned in changelog |
| 56 | +unmentioned_prs=() |
| 57 | + |
| 58 | +for pr in "${all_prs[@]}"; do |
| 59 | + if [[ ! " ${mentioned_prs[*]} " =~ " $pr " ]]; then |
| 60 | + unmentioned_prs+=($pr) |
| 61 | + fi |
| 62 | +done |
| 63 | + |
| 64 | +# Display results |
| 65 | +if [[ ${#unmentioned_prs[@]} -eq 0 ]]; then |
| 66 | + echo "✅ All PRs are mentioned in the changelog!" |
| 67 | +else |
| 68 | + echo "📋 PRs not mentioned in changelog (${#unmentioned_prs[@]} total):" |
| 69 | + echo |
| 70 | + |
| 71 | + for pr in "${unmentioned_prs[@]}"; do |
| 72 | + # Get PR title and URL for better readability |
| 73 | + pr_info=$(gh pr view "$pr" --json title,url --jq '{title: .title, url: .url}') |
| 74 | + pr_title=$(echo "$pr_info" | jq -r '.title') |
| 75 | + pr_url=$(echo "$pr_info" | jq -r '.url') |
| 76 | + |
| 77 | + echo " #$pr: $pr_title" |
| 78 | + echo " $pr_url" |
| 79 | + echo |
| 80 | + done |
| 81 | +fi |
0 commit comments