Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new release notes below the Unreleased section of changelogs #15332

Merged
merged 1 commit into from
Jul 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,23 @@ def changelog(
# write the new changelog in memory
changelog_buffer = StringIO()

# preserve the title
changelog_buffer.write(''.join(old[:2]))
# find the first header below the Unreleased section
header_index = 2
for index in range(2, len(old)):
if old[index].startswith("##") and "## Unreleased" not in old[index]:
header_index = index
break

# preserve the title and unreleased section
changelog_buffer.write(''.join(old[:header_index]))

# prepend the new changelog to the old contents
# make the command idempotent
if header not in old:
changelog_buffer.write(new_entry.getvalue())

# append the rest of the old changelog
changelog_buffer.write(''.join(old[2:]))
changelog_buffer.write(''.join(old[header_index:]))

write_result(dry_run, changelog_path, changelog_buffer.getvalue(), generated_changelogs)

Expand Down
Loading