Skip to content

Commit

Permalink
Improve helm chart annotation building script (apache#39286)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jedcunningham authored Apr 27, 2024
1 parent 48c98bc commit 60b17bb
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions dev/chart/build_changelog_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from __future__ import annotations

import re
from textwrap import indent

import yaml

Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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="")

0 comments on commit 60b17bb

Please sign in to comment.