From 60b17bb78a90b27c073318b14e4c1536e2122f48 Mon Sep 17 00:00:00 2001 From: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com> Date: Sat, 27 Apr 2024 09:55:47 -0400 Subject: [PATCH] Improve helm chart annotation building script (#39286) Very minor improvement, but this gets rid of a bunch of extra newlines and properly indents the annotations, allowing for an append redirect right into Chart.yaml. --- dev/chart/build_changelog_annotations.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dev/chart/build_changelog_annotations.py b/dev/chart/build_changelog_annotations.py index efc48857dbf4d..4ab3ea5823920 100755 --- a/dev/chart/build_changelog_annotations.py +++ b/dev/chart/build_changelog_annotations.py @@ -39,6 +39,7 @@ from __future__ import annotations import re +from textwrap import indent import yaml @@ -67,7 +68,7 @@ def parse_line(line: str) -> tuple[str | None, int | None]: return desc.strip(), int(pr_number) -def print_entry(section: str, description: str, pr_number: int | None): +def get_entry(section: str, description: str, pr_number: int | None) -> dict[str, str | list]: for unwanted_prefix in PREFIXES_TO_STRIP: if description.lower().startswith(unwanted_prefix.lower()): description = description[len(unwanted_prefix) :].strip() @@ -80,12 +81,13 @@ def print_entry(section: str, description: str, pr_number: int | None): entry["links"] = [ {"name": f"#{pr_number}", "url": f"https://github.com/apache/airflow/pull/{pr_number}"} ] - print(yaml.dump([entry])) + return entry in_first_release = False past_significant_changes = False section = "" +entries = [] with open("chart/RELEASE_NOTES.rst") as f: for line in f: line = line.strip() @@ -106,4 +108,7 @@ def print_entry(section: str, description: str, pr_number: int | None): else: description, pr = parse_line(line) if description: - print_entry(section, description, pr) + entries.append(get_entry(section, description, pr)) + +if entries: + print(indent(yaml.dump(entries), " " * 4), end="")