From 860b34cf07661f4ed0fe038a3a7d8b83296e2ad2 Mon Sep 17 00:00:00 2001 From: Jade Lovelace Date: Sun, 7 Apr 2024 20:02:18 -0700 Subject: [PATCH] build-release-notes: support multiple PRs/CLs Change-Id: I923e4af099d02d2324777cc9f7e6d38b130aac10 --- maintainers/build-release-notes.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/maintainers/build-release-notes.py b/maintainers/build-release-notes.py index 00c91e5da..dd26fd1cb 100644 --- a/maintainers/build-release-notes.py +++ b/maintainers/build-release-notes.py @@ -28,8 +28,7 @@ def format_issue(issue: str) -> str: return format_link(issue, "issues", "issues") def format_pr(pr: str) -> str: return format_link(pr, "pull", "pulls") -def format_cl(cl: str) -> str: - clid = int(cl) +def format_cl(clid: int) -> str: return f"[cl/{clid}]({GERRIT_BASE}/{clid})" paths = pathlib.Path(sys.argv[1]).glob('*.md') @@ -47,13 +46,19 @@ for p in paths: e.add_note(f"in {p}") raise +def listify(l: list | int) -> list: + if not isinstance(l, list): + return [l] + else: + return l + for p, entry in sorted(entries, key=lambda e: (-SIGNIFICANCECES[e[1].metadata.get('significance')], e[0])): try: header = entry.metadata['synopsis'] links = [] - links += map(format_issue, str(entry.metadata.get('issues', "")).split()) - links += map(format_pr, str(entry.metadata.get('prs', "")).split()) - links += map(format_cl, str(entry.metadata.get('cls', "")).split()) + links += [format_issue(str(s)) for s in listify(entry.metadata.get('issues', []))] + links += [format_pr(str(s)) for s in listify(entry.metadata.get('prs', []))] + links += [format_cl(cl) for cl in listify(entry.metadata.get('cls', []))] if links != []: header += " " + " ".join(links) if header: