mirror of
https://github.com/ARMmbed/mbedtls.git
synced 2025-05-11 01:11:42 +08:00
Initial changelog support for changelog assembling
Add an initial changelog if no entries found un the changelog. Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
This commit is contained in:
parent
effdfe7409
commit
ddffa10264
13
scripts/assemble_changelog.py
Executable file → Normal file
13
scripts/assemble_changelog.py
Executable file → Normal file
@ -127,10 +127,17 @@ class TextChangelogFormat(ChangelogFormat):
|
|||||||
def extract_top_version(cls, changelog_file_content):
|
def extract_top_version(cls, changelog_file_content):
|
||||||
"""A version section starts with a line starting with '='."""
|
"""A version section starts with a line starting with '='."""
|
||||||
m = re.search(cls._top_version_re, changelog_file_content)
|
m = re.search(cls._top_version_re, changelog_file_content)
|
||||||
|
if m:
|
||||||
top_version_start = m.start(1)
|
top_version_start = m.start(1)
|
||||||
top_version_end = m.end(2)
|
top_version_end = m.end(2)
|
||||||
top_version_title = m.group(1)
|
top_version_title = m.group(1)
|
||||||
top_version_body = m.group(2)
|
top_version_body = m.group(2)
|
||||||
|
# No entries found
|
||||||
|
else:
|
||||||
|
top_version_start = None
|
||||||
|
top_version_end = None
|
||||||
|
top_version_title = ''
|
||||||
|
top_version_body = ''
|
||||||
if cls.is_released_version(top_version_title):
|
if cls.is_released_version(top_version_title):
|
||||||
top_version_end = top_version_start
|
top_version_end = top_version_start
|
||||||
top_version_title = cls._unreleased_version_text + '\n\n'
|
top_version_title = cls._unreleased_version_text + '\n\n'
|
||||||
@ -244,7 +251,11 @@ class ChangeLog:
|
|||||||
self.categories = OrderedDict()
|
self.categories = OrderedDict()
|
||||||
for category in STANDARD_CATEGORIES:
|
for category in STANDARD_CATEGORIES:
|
||||||
self.categories[category] = ''
|
self.categories[category] = ''
|
||||||
|
if self.header:
|
||||||
offset = (self.header + self.top_version_title).count('\n') + 1
|
offset = (self.header + self.top_version_title).count('\n') + 1
|
||||||
|
else:
|
||||||
|
offset = 0
|
||||||
|
|
||||||
self.add_categories_from_text(input_stream.name, offset,
|
self.add_categories_from_text(input_stream.name, offset,
|
||||||
top_version_body, True)
|
top_version_body, True)
|
||||||
|
|
||||||
@ -258,7 +269,9 @@ class ChangeLog:
|
|||||||
"""Write the changelog to the specified file.
|
"""Write the changelog to the specified file.
|
||||||
"""
|
"""
|
||||||
with open(filename, 'w', encoding='utf-8') as out:
|
with open(filename, 'w', encoding='utf-8') as out:
|
||||||
|
if self.header:
|
||||||
out.write(self.header)
|
out.write(self.header)
|
||||||
|
if self.top_version_title:
|
||||||
out.write(self.top_version_title)
|
out.write(self.top_version_title)
|
||||||
for title, body in self.categories.items():
|
for title, body in self.categories.items():
|
||||||
if not body:
|
if not body:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user