Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:17:58

0001 #!/usr/bin/env python3
0002 
0003 import re
0004 
0005 import ghapi.all
0006 from rich import print
0007 from rich.syntax import Syntax
0008 
0009 ENTRY = re.compile(
0010     r"""
0011     Suggested \s changelog \s entry:
0012     .*
0013     ```rst
0014     \s*
0015     (.*?)
0016     \s*
0017     ```
0018 """,
0019     re.DOTALL | re.VERBOSE,
0020 )
0021 
0022 print()
0023 
0024 
0025 api = ghapi.all.GhApi(owner="pybind", repo="pybind11")
0026 
0027 issues_pages = ghapi.page.paged(
0028     api.issues.list_for_repo, labels="needs changelog", state="closed"
0029 )
0030 issues = (issue for page in issues_pages for issue in page)
0031 missing = []
0032 
0033 for issue in issues:
0034     changelog = ENTRY.findall(issue.body or "")
0035     if not changelog or not changelog[0]:
0036         missing.append(issue)
0037     else:
0038         (msg,) = changelog
0039         if not msg.startswith("* "):
0040             msg = "* " + msg
0041         if not msg.endswith("."):
0042             msg += "."
0043 
0044         msg += f"\n  `#{issue.number} <{issue.html_url}>`_"
0045 
0046         print(Syntax(msg, "rst", theme="ansi_light", word_wrap=True))
0047         print()
0048 
0049 if missing:
0050     print()
0051     print("[blue]" + "-" * 30)
0052     print()
0053 
0054     for issue in missing:
0055         print(f"[red bold]Missing:[/red bold][red] {issue.title}")
0056         print(f"[red]  {issue.html_url}\n")
0057 
0058     print("[bold]Template:\n")
0059     msg = "## Suggested changelog entry:\n\n```rst\n\n```"
0060     print(Syntax(msg, "md", theme="ansi_light"))
0061 
0062 print()