Skip to content

Commit

Permalink
new release notes added below the Unreleased section of changelog (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
swang392 authored Jul 21, 2023
1 parent 2a27c90 commit d723344
Showing 1 changed file with 10 additions and 3 deletions.
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

0 comments on commit d723344

Please sign in to comment.