github.com/kaydxh/golang@v0.0.131/pkg/gocv/cgo/third_path/pybind11/tools/make_changelog.py (about) 1 #!/usr/bin/env python3 2 3 import re 4 5 import ghapi.all 6 from rich import print 7 from rich.syntax import Syntax 8 9 ENTRY = 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 22 print() 23 24 25 api = ghapi.all.GhApi(owner="pybind", repo="pybind11") 26 27 issues_pages = ghapi.page.paged( 28 api.issues.list_for_repo, labels="needs changelog", state="closed" 29 ) 30 issues = (issue for page in issues_pages for issue in page) 31 missing = [] 32 33 for 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 49 if 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 62 print()