1313section and bullet, is reported on stderr and excluded.
1414
1515By default writes to stdout. Use --splice to rewrite CHANGELOG.md in
16- place, replacing just the `## Unreleased` block and preserving any
17- unlinked summary bullets under `### 🚫 Deprecations` by pulling them
18- forward into the new block .
16+ place, replacing the entire `## Unreleased` block. Any hand-written
17+ content in that block is discarded; review the resulting diff to recover
18+ anything worth keeping .
1919"""
2020
2121from __future__ import annotations
4242PR_URL = "https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/{pr}"
4343
4444
45- def extract_unlinked_deprecations (changelog_text : str ) -> list [str ]:
46- """Return bullet blocks under ## Unreleased / ### 🚫 Deprecations that
47- have no PR link, preserving multi-line wrapping."""
48- m = re .search (r"^## Unreleased\n(.*?)(?=^## |\Z)" , changelog_text , re .S | re .M )
49- if not m :
50- return []
51- unreleased = m .group (1 )
52- m = re .search (
53- r"^### 🚫 Deprecations\n(.*?)(?=^### |\Z)" ,
54- unreleased ,
55- re .S | re .M ,
56- )
57- if not m :
58- return []
59- section = m .group (1 )
60- # Split into bullet blocks. A bullet starts with "- " at column 0 and runs
61- # until the next "- " at column 0; indented lines and blank lines inside
62- # a bullet are absorbed, anything else outside a bullet is dropped.
63- blocks : list [list [str ]] = []
64- for line in section .splitlines ():
65- if line .startswith ("- " ):
66- blocks .append ([line ])
67- elif blocks and (line .startswith (" " ) or not line .strip ()):
68- blocks [- 1 ].append (line )
69- # Keep only blocks without a PR link.
70- return [
71- b for b in ("\n " .join (lines ).rstrip () for lines in blocks )
72- if b and not re .search (r"\[#\d+\]\(" , b )
73- ]
74-
75-
7645def load_decisions () -> list [dict ]:
7746 out = []
7847 if not BUNDLE_ROOT .is_dir ():
@@ -168,26 +137,17 @@ def main() -> int:
168137 continue
169138 grouped [section ].append (d )
170139
171- unlinked_deprecations : list [str ] = []
172- if args .splice and CHANGELOG .exists ():
173- unlinked_deprecations = extract_unlinked_deprecations (
174- CHANGELOG .read_text (encoding = "utf-8" )
175- )
176-
177140 out_lines = [
178141 "## Unreleased" ,
179142 "" ,
180143 ]
181144
182145 for key , header in SECTION_ORDER :
183146 items = sorted (grouped [key ], key = lambda d : d ["pr" ])
184- preserved = unlinked_deprecations if key == "deprecations" else []
185- if not items and not preserved :
147+ if not items :
186148 continue
187149 out_lines .append (header )
188150 out_lines .append ("" )
189- for block in preserved :
190- out_lines .append (block )
191151 for d in items :
192152 out_lines .append (format_bullet (d ["bullet" ], d ["pr" ]))
193153 out_lines .append ("" )
@@ -208,17 +168,14 @@ def main() -> int:
208168 new_text = text [: m .start ()] + block + "\n " + text [m .end ():]
209169 CHANGELOG .write_text (new_text , encoding = "utf-8" )
210170 bullet_count = sum (len (v ) for v in grouped .values ())
211- suffix = f", { len (unlinked_deprecations )} unlinked deprecation(s) preserved" if unlinked_deprecations else ""
212- print (f"Rewrote { CHANGELOG } ({ bullet_count } PR-linked bullets{ suffix } )" , file = sys .stderr )
171+ print (f"Rewrote { CHANGELOG } ({ bullet_count } PR-linked bullets)" , file = sys .stderr )
213172 else :
214173 sys .stdout .write (block )
215174
216175 if args .report :
217176 print ("Section counts:" , file = sys .stderr )
218177 for key , header in SECTION_ORDER :
219178 print (f" { key } : { len (grouped [key ])} " , file = sys .stderr )
220- if unlinked_deprecations :
221- print (f" unlinked-deprecations preserved: { len (unlinked_deprecations )} " , file = sys .stderr )
222179
223180 return 1 if errors else 0
224181
0 commit comments