Recognize an empty version section

Fix the case when there are no pending changes in the top version section.
This is not generally expected to happen, but it can happen when following
the release process and there have not yet been any changes since the last
release.

Signed-off-by: Gilles Peskine <[email protected]>
This commit is contained in:
Gilles Peskine
2026-07-20 10:53:29 +02:00
parent a802be7a02
commit f3c8d9c1a9
+4 -3
View File
@@ -116,7 +116,7 @@ class TextChangelogFormat(ChangelogFormat):
# Look for an incomplete release date
return not re.search(r'[0-9x]{4}-[0-9x]{2}-[0-9x]?x', title)
_top_version_re = re.compile(r'(?:\A|\n)(=[^\n]*\n+)(.*?\n)(?:=|$)',
_top_version_re = re.compile(r'(?:\A|\n)(=[^\n]*\n)(.*?)(?:\n=|\Z)',
re.DOTALL)
_name_re = re.compile(r'=\s(.*)\s[0-9x]+\.', re.DOTALL)
@classmethod
@@ -126,7 +126,7 @@ class TextChangelogFormat(ChangelogFormat):
top_version_start = m.start(1)
top_version_end = m.end(2)
top_version_title = m.group(1)
top_version_body = m.group(2)
top_version_body = m.group(2).strip('\n') + '\n'
name = re.match(cls._name_re, top_version_title).group(1)
if cls.is_released_version(top_version_title):
top_version_end = top_version_start
@@ -136,11 +136,12 @@ class TextChangelogFormat(ChangelogFormat):
top_version_title, top_version_body,
changelog_file_content[top_version_end:])
_newlines_only_re = re.compile(r'\n*\Z')
_category_title_re = re.compile(r'(^\w.*)\n+', re.MULTILINE)
@classmethod
def split_categories(cls, version_body):
"""A category title is a line with the title in column 0."""
if not version_body:
if cls._newlines_only_re.match(version_body):
return []
title_matches = list(re.finditer(cls._category_title_re, version_body))
if not title_matches or title_matches[0].start() != 0: