Enable to specify the name of the project in the changelog

The name read out from the previous entry.

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
This commit is contained in:
Gabor Mezei 2023-11-21 17:05:43 +01:00
parent ddffa10264
commit 8933c04e44
No known key found for this signature in database
GPG Key ID: F072ACA227ACD71D

7
scripts/assemble_changelog.py Normal file → Executable file
View File

@ -115,7 +115,7 @@ class ChangelogFormat:
class TextChangelogFormat(ChangelogFormat):
"""The traditional Mbed TLS changelog format."""
_unreleased_version_text = '= Mbed TLS x.x.x branch released xxxx-xx-xx'
_unreleased_version_text = '= {} x.x.x branch released xxxx-xx-xx'
@classmethod
def is_released_version(cls, title):
# Look for an incomplete release date
@ -123,6 +123,7 @@ class TextChangelogFormat(ChangelogFormat):
_top_version_re = re.compile(r'(?:\A|\n)(=[^\n]*\n+)(.*?\n)(?:=|$)',
re.DOTALL)
_name_re = re.compile(r'=\s(.*)\s[0-9x]+\.', re.DOTALL)
@classmethod
def extract_top_version(cls, changelog_file_content):
"""A version section starts with a line starting with '='."""
@ -132,15 +133,17 @@ class TextChangelogFormat(ChangelogFormat):
top_version_end = m.end(2)
top_version_title = m.group(1)
top_version_body = m.group(2)
name = re.match(cls._name_re, top_version_title).group(1)
# No entries found
else:
top_version_start = None
top_version_end = None
name = 'xxx'
top_version_title = ''
top_version_body = ''
if cls.is_released_version(top_version_title):
top_version_end = top_version_start
top_version_title = cls._unreleased_version_text + '\n\n'
top_version_title = cls._unreleased_version_text.format(name) + '\n\n'
top_version_body = ''
return (changelog_file_content[:top_version_start],
top_version_title, top_version_body,