| 36 | |
| 37 | |
| 38 | def parse_changelog(tag_name): |
| 39 | p = Path(__file__).parent.parent / "doc/en/changelog.rst" |
| 40 | changelog_lines = p.read_text(encoding="UTF-8").splitlines() |
| 41 | |
| 42 | title_regex = re.compile(r"pytest (\d\.\d+\.\d+) \(\d{4}-\d{2}-\d{2}\)") |
| 43 | consuming_version = False |
| 44 | version_lines = [] |
| 45 | for line in changelog_lines: |
| 46 | m = title_regex.match(line) |
| 47 | if m: |
| 48 | # found the version we want: start to consume lines until we find the next version title |
| 49 | if m.group(1) == tag_name: |
| 50 | consuming_version = True |
| 51 | # found a new version title while parsing the version we want: break out |
| 52 | elif consuming_version: |
| 53 | break |
| 54 | if consuming_version: |
| 55 | version_lines.append(line) |
| 56 | |
| 57 | return "\n".join(version_lines) |
| 58 | |
| 59 | |
| 60 | def convert_rst_to_md(text): |