fix Update changelog in api generator (#675)

Signed-off-by: saimedhi <[email protected]>
This commit is contained in:
Sai Medhini Reddy Maryada
2024-02-09 08:47:11 -05:00
committed by GitHub
parent 8b91bb4ddb
commit b2638fbb47
+12 -11
View File
@@ -779,17 +779,18 @@ def dump_modules(modules: Any) -> None:
with open("CHANGELOG.md", "r+", encoding="utf-8") as file: with open("CHANGELOG.md", "r+", encoding="utf-8") as file:
content = file.read() content = file.read()
if "### Updated APIs" in content: if commit_url not in content:
file_content = content.replace( if "### Updated APIs" in content:
"### Updated APIs", file_content = content.replace(
f"### Updated APIs\n- Updated opensearch-py APIs to reflect [opensearch-api-specification@{latest_commit_sha[:7]}]({commit_url})", "### Updated APIs",
1, 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.seek(0)
file.truncate() file.write(file_content)
else: file.truncate()
raise Exception("'Updated APIs' section is not present in CHANGELOG.md") else:
raise Exception("'Updated APIs' section is not present in CHANGELOG.md")
if __name__ == "__main__": if __name__ == "__main__":