From 6208f21231a7301d3383b56e698a823deaa08e05 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 27 Apr 2024 11:55:03 +0200 Subject: [PATCH] Do not clobber existing release summary. --- .../fragments/597-release_summary-overwrite.yml | 2 ++ src/antsibull/build_ansible_commands.py | 1 + src/antsibull/changelog.py | 12 ++++++++++-- 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/597-release_summary-overwrite.yml diff --git a/changelogs/fragments/597-release_summary-overwrite.yml b/changelogs/fragments/597-release_summary-overwrite.yml new file mode 100644 index 00000000..a40096d7 --- /dev/null +++ b/changelogs/fragments/597-release_summary-overwrite.yml @@ -0,0 +1,2 @@ +minor_changes: + - "The ``prepare`` subcommand will no longer overwrite an existing release summary in the ``changelog.yaml`` file (https://github.com/ansible-community/antsibull/pull/597)." diff --git a/src/antsibull/build_ansible_commands.py b/src/antsibull/build_ansible_commands.py index 06bb2744..04c90b6a 100644 --- a/src/antsibull/build_ansible_commands.py +++ b/src/antsibull/build_ansible_commands.py @@ -431,6 +431,7 @@ def prepare_command() -> int: f"Release Date: {date}" f"\n\n" f"`Porting Guide `_", + overwrite_release_summary=False, ) ansible_changelog.changes.save() diff --git a/src/antsibull/changelog.py b/src/antsibull/changelog.py index a7b1a8a1..452b38e5 100644 --- a/src/antsibull/changelog.py +++ b/src/antsibull/changelog.py @@ -116,7 +116,11 @@ def concatenate(cls, changelogs: list[ChangelogData]) -> ChangelogData: ) def add_ansible_release( - self, version: str, date: datetime.date, release_summary: str + self, + version: str, + date: datetime.date, + release_summary: str, + overwrite_release_summary: bool = True, ) -> None: add_release( self.config, @@ -132,7 +136,11 @@ def add_ansible_release( release_date = self.changes.releases[version] if "changes" not in release_date: release_date["changes"] = {} - release_date["changes"]["release_summary"] = release_summary + if ( + "release_summary" not in release_date["changes"] + or overwrite_release_summary + ): + release_date["changes"]["release_summary"] = release_summary def read_file(tarball_path: str, matcher: t.Callable[[str], bool]) -> bytes | None: