From b34081efdb629414b65daf66e47432f37df1b578 Mon Sep 17 00:00:00 2001 From: "bazel.build machine account" Date: Wed, 22 Jan 2025 22:53:16 +0100 Subject: [PATCH] [7.5.0] Update relnotes script to follow the patch release format for minor releases with no RELNOTES tags (#25025) PiperOrigin-RevId: 718504556 Change-Id: I54f42e07721935c44a6f2a314b59864d6433d865 Commit https://github.com/bazelbuild/bazel/commit/c38bed0592ad2a2a5a8402dc0fb625ea63c6643d Co-authored-by: Googler --- scripts/release/relnotes.py | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/scripts/release/relnotes.py b/scripts/release/relnotes.py index 0caf749ee9ccde..8d42ed34bf33d6 100644 --- a/scripts/release/relnotes.py +++ b/scripts/release/relnotes.py @@ -163,6 +163,20 @@ def get_external_authors_between(base, head): return ", ".join(sorted(authors.union(coauthors), key=str.casefold)) +def get_filtered_notes(base, previous_release, is_patch_release): + # Generate notes for all commits from last branch cut to HEAD, but filter out + # any identical notes from the previous release branch. + cur_release_relnotes = get_relnotes_between( + base, "HEAD", is_patch_release + ) + last_release_relnotes = set( + get_relnotes_between(base, previous_release, is_patch_release) + ) + return [ + note for note in cur_release_relnotes if note not in last_release_relnotes + ] + + if __name__ == "__main__": # Get last release and make sure it's consistent with current X.Y.Z release # e.g. if current_release is 5.3.3, last_release should be 5.3.2 even if @@ -194,17 +208,7 @@ def get_external_authors_between(base, head): # for. merge_base = git("merge-base", "HEAD", last_release)[0] - # Generate notes for all commits from last branch cut to HEAD, but filter out - # any identical notes from the previous release branch. - cur_release_relnotes = get_relnotes_between( - merge_base, "HEAD", is_patch - ) - last_release_relnotes = set( - get_relnotes_between(merge_base, last_release, is_patch) - ) - filtered_relnotes = [ - note for note in cur_release_relnotes if note not in last_release_relnotes - ] + filtered_relnotes = get_filtered_notes(merge_base, last_release, is_patch) # Reverse so that the notes are in chronological order. filtered_relnotes.reverse() @@ -212,6 +216,13 @@ def get_external_authors_between(base, head): print("Release Notes:") print() + # For minor releases w/o any RELNOTES tags, follow the patch release format to + # get release notes (PR title instead of RELNOTES tag) + # Not applicable for major or patch releases + if all(not note for note in filtered_relnotes) and is_patch == 0: + is_patch = True + filtered_relnotes = get_filtered_notes(merge_base, last_release, is_patch) + categorized_release_notes = get_categorized_relnotes(filtered_relnotes) for label in categorized_release_notes: print(label + ":")