MCPcopy Create free account
hub / github.com/apache/solr / strip_unreleased_block

Function strip_unreleased_block

dev-tools/scripts/logchange.py:90–123  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

88
89
90def 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
126def validate_unreleased_yamls(git_root, dry_run=False):

Callers 1

run_logchange_generateFunction · 0.85

Calls 2

existsMethod · 0.65
subMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…