μ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# -*- coding: utf-8 -*-
3
4import re
5
6import ghapi.all
7from rich import print
8from rich.syntax import Syntax
9
10ENTRY = re.compile(
11 r"""
12 Suggested \s changelog \s entry:
13 .*
14 ```rst
15 \s*
16 (.*?)
17 \s*
18 ```
19""",
20 re.DOTALL | re.VERBOSE,
21)
22
23print()
24
25
26api = ghapi.all.GhApi(owner="pybind", repo="pybind11")
27
28issues_pages = ghapi.page.paged(
29 api.issues.list_for_repo, labels="needs changelog", state="closed"
30)
31issues = (issue for page in issues_pages for issue in page)
32missing = []
33
34for issue in issues:
35 changelog = ENTRY.findall(issue.body)
36 if changelog:
37 (msg,) = changelog
38 if not msg.startswith("* "):
39 msg = "* " + msg
40 if not msg.endswith("."):
41 msg += "."
42
43 msg += f"\n `#{issue.number} <{issue.html_url}>`_"
44
45 print(Syntax(msg, "rst", theme="ansi_light", word_wrap=True))
46 print()
47
48 else:
49 missing.append(issue)
50
51if missing:
52 print()
53 print("[blue]" + "-" * 30)
54 print()
55
56 for issue in missing:
57 print(f"[red bold]Missing:[/red bold][red] {issue.title}")
58 print(f"[red] {issue.html_url}\n")
59
60 print("[bold]Template:\n")
61 msg = "## Suggested changelog entry:\n\n```rst\n\n```"
62 print(Syntax(msg, "md", theme="ansi_light"))
63
64print()