Skip to content

Commit 11313da

Browse files
authored
Include subheaders in script output (#10212)
* Include subheaders in script output When selecting a specific version, we want to include all its subheaders in the generated output. * Line too long. * Fix indentation
1 parent be0934d commit 11313da

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

scripts/make_release_notes.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,22 +256,29 @@ def read_changelog_section(filename, single_version=None):
256256
# Discard all lines until we see a heading that either has the version the
257257
# user asked for or any version.
258258
if single_version:
259-
initial_heading = re.compile(r'^#{1,6} .*%s' % re.escape(single_version))
259+
initial_heading = re.compile(
260+
r'^(#{1,6}) .*%s' % re.escape(single_version))
260261
else:
261-
initial_heading = re.compile(r'^#{1,6} ([^\d]*)\d')
262+
initial_heading = re.compile(r'^#({1,6}) ([^\d]*)\d')
262263

263-
heading = re.compile(r'^#{1,6} ')
264+
heading = re.compile(r'^(#{1,6}) ')
264265

265266
initial = True
267+
heading_level = 6
266268
result = []
267269
for line in fd:
268270
if initial:
269-
if initial_heading.match(line):
271+
match = initial_heading.match(line)
272+
if match:
270273
initial = False
274+
heading_level = len(match.group(1))
271275
result.append(line)
272276

273277
else:
274-
if heading.match(line):
278+
match = heading.match(line)
279+
# We only break if we find a new header at the same, or higher,
280+
# level.
281+
if match and len(match.group(1)) <= heading_level:
275282
break
276283

277284
result.append(line)

0 commit comments

Comments
 (0)