From 7bac199950457c61b86f681581d724f6ef7c80d8 Mon Sep 17 00:00:00 2001 From: Aakash N S <1560745+aakashns@users.noreply.github.com> Date: Mon, 19 Oct 2026 15:43:31 +0700 Subject: [PATCH] Release notes list squash-merged pull requests too Since pull requests started being squash-merged (from #24), the release notes found no merge commits and came out empty but for the changelog link, as on 0.18.0 and 0.19.0. A squashed pull request is now found by the "(#N)" its commit ends with, and its own commits are fetched from GitHub, so each one's full message is listed as before. Merge commits still work the same. Co-Authored-By: Claude Opus 5.5 --- .github/release-notes.sh | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/.github/release-notes.sh b/.github/release-notes.sh index 0cb4b70..3912768 100755 --- a/.github/release-notes.sh +++ b/.github/release-notes.sh @@ -1,12 +1,13 @@ #!/usr/bin/env bash # Prints the release notes for a version: for each pull request merged since -# the last release, its title, then the full message of each of its commits -# (without the Co-Authored-By lines). +# the last release (with a merge commit or squashed), its title, then the +# full message of each of its commits (without the Co-Authored-By lines). # # .github/release-notes.sh 0.15.0 [ref] # # `ref` (default HEAD) is what's being released. Needs the tags and the full -# history (actions/checkout with fetch-depth: 0). +# history (actions/checkout with fetch-depth: 0), and fetches squashed pull +# requests' commits from GitHub. set -euo pipefail # Commit messages are wrapped at about 72 columns, and GitHub shows every @@ -30,14 +31,26 @@ repo=https://github.com/aakashns/writui prev=$(git describe --tags --abbrev=0 "$ref^" 2>/dev/null || true) echo "## What's changed" -for merge in $(git rev-list --merges --first-parent --reverse "${prev:+$prev..}$ref"); do - pr=$(git log -1 --format=%s "$merge" | sed -n 's/^Merge pull request #\([0-9]*\) .*/\1/p') - [ -n "$pr" ] || continue - # GitHub puts the pull request's title in the merge commit's body. - title=$(git log -1 --format=%b "$merge" | head -1) +for merge in $(git rev-list --first-parent --reverse "${prev:+$prev..}$ref"); do + subject=$(git log -1 --format=%s "$merge") + pr=$(echo "$subject" | sed -n 's/^Merge pull request #\([0-9]*\) .*/\1/p') + if [ -n "$pr" ]; then + # A merge commit: GitHub puts the pull request's title in its body, + # and its second parent is the pull request's last commit. + title=$(git log -1 --format=%b "$merge" | head -1) + head=$merge^2 + else + # A squash merge: "Title (#12)". The pull request's own commits are + # still on GitHub, at pull/12/head. + pr=$(echo "$subject" | sed -n 's/.* (#\([0-9]*\))$/\1/p') + [ -n "$pr" ] || continue + title=${subject% (#"$pr")} + head=refs/writui-notes/pr-$pr + git fetch -q origin "+pull/$pr/head:$head" + fi echo echo "### $title ([#$pr]($repo/pull/$pr))" - for commit in $(git rev-list --no-merges --reverse "$merge^1..$merge^2"); do + for commit in $(git rev-list --no-merges --reverse "$merge^1..$head"); do echo echo "**$(git log -1 --format=%s "$commit")**" body=$(git log -1 --format=%b "$commit" | grep -vi '^co-authored-by:' || true)