μHAL (v2.8.17)
Part of the IPbus software repository
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
make_changelog.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2
3import re
4
5import ghapi.all
6from rich import print
7from rich.syntax import Syntax
8
9ENTRY = re.compile(
10 r"""
11 Suggested \s changelog \s entry:
12 .*
13 ```rst
14 \s*
15 (.*?)
16 \s*
17 ```
18""",
19 re.DOTALL | re.VERBOSE,
20)
21
22print()
23
24
25api = ghapi.all.GhApi(owner="pybind", repo="pybind11")
26
27issues_pages = ghapi.page.paged(
28 api.issues.list_for_repo, labels="needs changelog", state="closed"
29)
30issues = (issue for page in issues_pages for issue in page)
31missing = []
32
33for issue in issues:
34 changelog = ENTRY.findall(issue.body or "")
35 if not changelog or not changelog[0]:
36 missing.append(issue)
37 else:
38 (msg,) = changelog
39 if not msg.startswith("* "):
40 msg = "* " + msg
41 if not msg.endswith("."):
42 msg += "."
43
44 msg += f"\n `#{issue.number} <{issue.html_url}>`_"
45
46 print(Syntax(msg, "rst", theme="ansi_light", word_wrap=True))
47 print()
48
49if missing:
50 print()
51 print("[blue]" + "-" * 30)
52 print()
53
54 for issue in missing:
55 print(f"[red bold]Missing:[/red bold][red] {issue.title}")
56 print(f"[red] {issue.html_url}\n")
57
58 print("[bold]Template:\n")
59 msg = "## Suggested changelog entry:\n\n```rst\n\n```"
60 print(Syntax(msg, "md", theme="ansi_light"))
61
62print()