Skip to content

Commit

Permalink
Update relnotes script to follow the patch release format for minor r…
Browse files Browse the repository at this point in the history
…eleases with no RELNOTES tags

PiperOrigin-RevId: 718504556
Change-Id: I54f42e07721935c44a6f2a314b59864d6433d865
  • Loading branch information
keertk authored and copybara-github committed Jan 22, 2025
1 parent f83ced6 commit c38bed0
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 c38bed0

Please sign in to comment.