Skip to content

Commit b389ae7

Browse files
authored
chore: update changelog script for categories (#4942)
1 parent e250155 commit b389ae7

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

tools/make_changelog.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python3
2+
from __future__ import annotations
23

34
import re
45

@@ -29,21 +30,46 @@
2930
)
3031
issues = (issue for page in issues_pages for issue in page)
3132
missing = []
33+
cats_descr = {
34+
"feat": "New Features",
35+
"fix": "Bug fixes",
36+
"fix(types)": "",
37+
"fix(cmake)": "",
38+
"docs": "Documentation",
39+
"tests": "Tests",
40+
"ci": "CI",
41+
"chore": "Other",
42+
"unknown": "Uncategorised",
43+
}
44+
cats: dict[str, list[str]] = {c: [] for c in cats_descr}
3245

3346
for issue in issues:
3447
changelog = ENTRY.findall(issue.body or "")
3548
if not changelog or not changelog[0]:
3649
missing.append(issue)
3750
else:
3851
(msg,) = changelog
52+
if msg.startswith("- "):
53+
msg = msg[2:]
3954
if not msg.startswith("* "):
4055
msg = "* " + msg
4156
if not msg.endswith("."):
4257
msg += "."
4358

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

46-
print(Syntax(msg, "rst", theme="ansi_light", word_wrap=True))
67+
for cat, msgs in cats.items():
68+
if msgs:
69+
desc = cats_descr[cat]
70+
print(f"[bold]{desc}:\n" if desc else "")
71+
for msg in msgs:
72+
print(Syntax(msg, "rst", theme="ansi_light", word_wrap=True))
4773
print()
4874

4975
if missing:

0 commit comments

Comments
 (0)