INNER CODE UNIT · Python
find_section_insert_at
fluxerapp/flutter_client · .github/scripts/append_release_direct_commits.py:216
def find_section_insert_at(body: str, section_heading: str) -> int:
try:
target_index = SECTION_ORDER.index(section_heading)
except ValueError:
return len(body.rstrip())
for later_heading in SECTION_ORDER[target_index + 1 :]:
match = re.search(rf"\n{re.escape(later_heading)}\n", body)
if match is not None:
return match.start()
detailed_match = re.search(rf"{re.escape(DETAILED_CHANGES_HEADING)}\n", body)
if detailed_match is not None:
return len(body.rstrip())
changes_match = re.search(r"## Changes\n", body)
if changes_match is not None:
return len(body.rstrip())
return len(body.rstrip())