ci(common): Fix changelog: only add newline for new entries

This commit is contained in:
David Cermak
2024-03-13 08:27:55 +01:00
parent dfb0035858
commit 16b79d170b

View File

@ -83,13 +83,14 @@ def main():
changelog += '\n### {}\n\n'.format(sections[section]) changelog += '\n### {}\n\n'.format(sections[section])
for it in item: for it in item:
changelog += '- {}\n'.format(it) changelog += '- {}\n'.format(it)
changelog += '\n'
filename = os.path.join(root_path, 'components', component, 'CHANGELOG.md') filename = os.path.join(root_path, 'components', component, 'CHANGELOG.md')
# Check if the changelog file exists. # Check if the changelog file exists.
if not os.path.exists(filename): if not os.path.exists(filename):
# File does not exist, create it # File does not exist, create it
with open(filename, 'w') as file: with open(filename, 'w') as file:
file.write('# Changelog\n\n') file.write('# Changelog\n\n')
else:
changelog += '\n'
# insert the actual changelog to the beginning of the file, just after the title (2nd line) # insert the actual changelog to the beginning of the file, just after the title (2nd line)
with open(filename, 'r') as orig_changelog: with open(filename, 'r') as orig_changelog:
changelog_title = orig_changelog.readline( changelog_title = orig_changelog.readline(