build-release-notes: support multiple PRs/CLs

Change-Id: I923e4af099d02d2324777cc9f7e6d38b130aac10
This commit is contained in:
jade 2024-04-07 20:02:18 -07:00
parent 5ec256625e
commit 860b34cf07

View file

@ -28,8 +28,7 @@ def format_issue(issue: str) -> str:
return format_link(issue, "issues", "issues") return format_link(issue, "issues", "issues")
def format_pr(pr: str) -> str: def format_pr(pr: str) -> str:
return format_link(pr, "pull", "pulls") return format_link(pr, "pull", "pulls")
def format_cl(cl: str) -> str: def format_cl(clid: int) -> str:
clid = int(cl)
return f"[cl/{clid}]({GERRIT_BASE}/{clid})" return f"[cl/{clid}]({GERRIT_BASE}/{clid})"
paths = pathlib.Path(sys.argv[1]).glob('*.md') paths = pathlib.Path(sys.argv[1]).glob('*.md')
@ -47,13 +46,19 @@ for p in paths:
e.add_note(f"in {p}") e.add_note(f"in {p}")
raise 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])): for p, entry in sorted(entries, key=lambda e: (-SIGNIFICANCECES[e[1].metadata.get('significance')], e[0])):
try: try:
header = entry.metadata['synopsis'] header = entry.metadata['synopsis']
links = [] links = []
links += map(format_issue, str(entry.metadata.get('issues', "")).split()) links += [format_issue(str(s)) for s in listify(entry.metadata.get('issues', []))]
links += map(format_pr, str(entry.metadata.get('prs', "")).split()) links += [format_pr(str(s)) for s in listify(entry.metadata.get('prs', []))]
links += map(format_cl, str(entry.metadata.get('cls', "")).split()) links += [format_cl(cl) for cl in listify(entry.metadata.get('cls', []))]
if links != []: if links != []:
header += " " + " ".join(links) header += " " + " ".join(links)
if header: if header: