zed/script/lib/release-notes.js
Finn Evers 93f9fce115
Require release notes to be present (#64238)
Release notes are the sole information users have about what could
either have improved or have been broken for them. Omitting release
notes is one thing, but not writing any or having empty ones helps
nobody - users get no context on what could cause issues they were
seeing nor do they know about potential improvements, triagers cannot
easily find the PR that could have introduced the bug either.

Thus, this PR now makes it so that danger actually requires one to write
release notes. Empty release notes or the placeholder will no longer be
accepted.

Release Notes:

- N/A
2026-09-15 13:38:45 +00:00

22 lines
891 B
JavaScript

function releaseNotesSection(body) {
// Inline mentions and bullet text must not override the final release notes heading.
const headings = [...body.matchAll(/^Release Notes:(?:\r?\n)+(?=- )/gim)];
const lastHeading = headings[headings.length - 1];
return lastHeading ? body.slice(lastHeading.index + lastHeading[0].length) : "";
}
function releaseNotesEntries(section) {
const entries = [];
// Blank lines can separate bullets, but a non-bullet paragraph ends the notes
// so commit trailers and other trailing text are not published as release notes.
for (const paragraph of section.split(/\r?\n(?:[ \t]*\r?\n)+/)) {
if (!paragraph.startsWith("- ")) {
break;
}
entries.push(...paragraph.split(/\r?\n(?=- )/).map((entry) => entry.trimEnd().replace(/\r?\n/g, " ")));
}
return entries;
}
module.exports = { releaseNotesSection, releaseNotesEntries };