From b2638fbb47c19b08d3146eb6755ee6d2ce43be6c Mon Sep 17 00:00:00 2001 From: Sai Medhini Reddy Maryada <117196660+saimedhi@users.noreply.github.com> Date: Fri, 9 Feb 2024 05:47:11 -0800 Subject: [PATCH] fix Update changelog in api generator (#675) Signed-off-by: saimedhi --- utils/generate_api.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/utils/generate_api.py b/utils/generate_api.py index 88a52028..c14c03c1 100644 --- a/utils/generate_api.py +++ b/utils/generate_api.py @@ -779,17 +779,18 @@ def dump_modules(modules: Any) -> None: with open("CHANGELOG.md", "r+", encoding="utf-8") as file: content = file.read() - if "### Updated APIs" in content: - file_content = content.replace( - "### Updated APIs", - f"### Updated APIs\n- Updated opensearch-py APIs to reflect [opensearch-api-specification@{latest_commit_sha[:7]}]({commit_url})", - 1, - ) - file.seek(0) - file.write(file_content) - file.truncate() - else: - raise Exception("'Updated APIs' section is not present in CHANGELOG.md") + if commit_url not in content: + if "### Updated APIs" in content: + file_content = content.replace( + "### Updated APIs", + f"### Updated APIs\n- Updated opensearch-py APIs to reflect [opensearch-api-specification@{latest_commit_sha[:7]}]({commit_url})", + 1, + ) + file.seek(0) + file.write(file_content) + file.truncate() + else: + raise Exception("'Updated APIs' section is not present in CHANGELOG.md") if __name__ == "__main__":