Skip to content

Commit

Permalink
release-tools: fix handling of NEWS.md items
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Pires <[email protected]>
  • Loading branch information
MiguelPires committed Nov 21, 2023
1 parent dc51d60 commit 3a88dc3
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions release-tools/changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import textwrap
from typing import NamedTuple

from bs4 import BeautifulSoup
from bs4 import BeautifulSoup, NavigableString, Tag

import debian.changelog

Expand Down Expand Up @@ -218,10 +218,18 @@ def read_changelogs_news_md(changelog: io.TextIOWrapper, new_version: str):
new_changelog = []
wrapper = textwrap.TextWrapper(initial_indent=" - ", subsequent_indent=" ", width=72)
for elm in soup.ul.children:
if not elm.text.strip():
if type(elm) is Tag:
text = elm.text
elif type(elm) is NavigableString:
text = elm
else:
raise RuntimeError(f'expected list item as Tag or NavigableString but got "{type(elm)}"')

if not text.strip():
continue

# li can be multiline, concat them
ch_entry = " ".join([line.strip() for line in elm.text.split("\n")])
ch_entry = " ".join([line.strip() for line in text.split("\n")])
# and wrap again but this time the Debian/Ubuntu way
new_changelog.append("\n".join(wrapper.wrap(ch_entry)))
new_changelog_str = "\n".join(new_changelog)
Expand Down

0 comments on commit 3a88dc3

Please sign in to comment.