Remove the [unreleased] block that logchangeGenerate emits. CHANGELOG.md uses logchange's setext-style headings, e.g.: [unreleased] ------------ ### Added ... ...content... [10.1.0] -------- We strip from the ``[unreleased]`` line up to (b
(changelog_path: Path, dry_run=False)
| 88 | |
| 89 | |
| 90 | def strip_unreleased_block(changelog_path: Path, dry_run=False): |
| 91 | """Remove the [unreleased] block that logchangeGenerate emits. |
| 92 | |
| 93 | CHANGELOG.md uses logchange's setext-style headings, e.g.: |
| 94 | |
| 95 | [unreleased] |
| 96 | ------------ |
| 97 | |
| 98 | ### Added ... |
| 99 | ...content... |
| 100 | |
| 101 | [10.1.0] |
| 102 | -------- |
| 103 | |
| 104 | We strip from the ``[unreleased]`` line up to (but not including) the next |
| 105 | versioned heading, identified by a ``[`` at the start of a line that is not |
| 106 | ``[unreleased]``. |
| 107 | """ |
| 108 | if not changelog_path.exists(): |
| 109 | print(" (CHANGELOG.md not found — skipping strip)") |
| 110 | return |
| 111 | text = changelog_path.read_text(encoding="utf-8") |
| 112 | cleaned = re.sub( |
| 113 | r'^\[unreleased\]\n(?:.*\n)*?(?=^\[(?!unreleased\]))', |
| 114 | '', |
| 115 | text, |
| 116 | flags=re.MULTILINE, |
| 117 | ) |
| 118 | if cleaned == text: |
| 119 | print(" (no [unreleased] block found in CHANGELOG.md — nothing stripped)") |
| 120 | return |
| 121 | print(" Stripped [unreleased] block from CHANGELOG.md") |
| 122 | if not dry_run: |
| 123 | changelog_path.write_text(cleaned, encoding="utf-8") |
| 124 | |
| 125 | |
| 126 | def validate_unreleased_yamls(git_root, dry_run=False): |
no test coverage detected
searching dependent graphs…