changelogNotes function
The release notes to publish for version on platform.
A version whose own section says nothing about this platform — empty, or
entirely [ios] — falls back to the newest earlier version that does. That
is not a workaround for a missing entry: a release still has to tell users
something, and the most recent thing this platform actually gained is a
truer answer than boilerplate. Only when nothing anywhere below qualifies
does noUserVisibleChanges go out.
The walk relies on the file being newest-first, which is the convention
CHANGELOG.md states and tool/build.sh --release half-enforces by requiring
a section for the version being built.
Implementation
Notes changelogNotes(
String markdown,
String version, {
required String platform,
}) {
final sections = _sections(markdown);
final start = sections.indexWhere((s) => s.version == version);
if (start < 0) {
return const NoSection();
}
for (var i = start; i < sections.length; i++) {
final kept = _forPlatform(sections[i].entries, platform);
if (kept.isNotEmpty) {
return NotesText(kept.join('\n'), fromVersion: sections[i].version);
}
}
return const NotesText(noUserVisibleChanges, fromVersion: '');
}