Files
manim-slides/.github/scripts/check_github_issues.py
Jérome Eertmans 04bca458f1 chore(ci): checking links and spell checking (#417)
* chore(ci): checking links and spell checking

* chore(ci): move markdown-link-check to GitHub ci

Because pre-commit.ci does not have access to the internet...

* fix(lib): revert `reverse-...` utils because of warnings

* chore(ci): checking links and spell checking

* chore(ci): move markdown-link-check to GitHub ci

Because pre-commit.ci does not have access to the internet...

* fix(docs): myst-parser xref cannot end with .html

* fix(docs): oops
2024-04-17 17:59:40 +02:00

28 lines
873 B
Python

"""Check that GitHub issues (and PR) links match the number in Markdown link."""
import glob
import re
import sys
if __name__ == "__main__":
p = re.compile(
r"\[#(?P<number1>[0-9]+)\]"
r"\(https://github\.com/"
r"(?:[a-zA-Z0-9_-]+)/(?:[a-zA-Z0-9_-]+)/"
r"(?:(?:issues)|(?:pull))/(?P<number2>[0-9]+)\)"
)
ret_code = 0
for glob_pattern in sys.argv[1:]:
for file in glob.glob(glob_pattern, recursive=True):
with open(file) as f:
for i, line in enumerate(f):
for m in p.finditer(line):
if m.group("number1") != m.group("number2"):
start, end = m.span()
print(f"{file}:{i}: ", line[start:end], file=sys.stderr) # noqa: T201
ret_code = 1
sys.exit(ret_code)