Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update changelog script for categories #4942

Merged
merged 1 commit into from
Nov 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion tools/make_changelog.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
from __future__ import annotations

import re

Expand Down Expand Up @@ -29,21 +30,46 @@
)
issues = (issue for page in issues_pages for issue in page)
missing = []
cats_descr = {
"feat": "New Features",
"fix": "Bug fixes",
"fix(types)": "",
"fix(cmake)": "",
"docs": "Documentation",
"tests": "Tests",
"ci": "CI",
"chore": "Other",
"unknown": "Uncategorised",
}
cats: dict[str, list[str]] = {c: [] for c in cats_descr}

for issue in issues:
changelog = ENTRY.findall(issue.body or "")
if not changelog or not changelog[0]:
missing.append(issue)
else:
(msg,) = changelog
if msg.startswith("- "):
msg = msg[2:]
if not msg.startswith("* "):
msg = "* " + msg
if not msg.endswith("."):
msg += "."

msg += f"\n `#{issue.number} <{issue.html_url}>`_"
for cat in cats:
if issue.title.lower().startswith(f"{cat}:"):
cats[cat].append(msg)
break
else:
cats["unknown"].append(msg)

print(Syntax(msg, "rst", theme="ansi_light", word_wrap=True))
for cat, msgs in cats.items():
if msgs:
desc = cats_descr[cat]
print(f"[bold]{desc}:\n" if desc else "")
for msg in msgs:
print(Syntax(msg, "rst", theme="ansi_light", word_wrap=True))
print()

if missing:
Expand Down