Skip to content

Commit

Permalink
[7.5.0] Update relnotes script to follow the patch release format for…
Browse files Browse the repository at this point in the history
… minor releases with no RELNOTES tags (#25025)

PiperOrigin-RevId: 718504556
Change-Id: I54f42e07721935c44a6f2a314b59864d6433d865

Commit
c38bed0

Co-authored-by: Googler <[email protected]>
  • Loading branch information
bazel-io and keertk authored Jan 22, 2025
1 parent 86f0b8e commit b34081e
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions scripts/release/relnotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -194,24 +208,21 @@ 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()
print()
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 + ":")
Expand Down

0 comments on commit b34081e

Please sign in to comment.