tools: add semver-major release support to release-lint

Co-authored-by: RafaelGSS <rafael.nunu@hotmail.com>
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/57892
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
This commit is contained in:
Antoine du Hamel 2025-04-21 08:33:57 +02:00 committed by GitHub
parent e773e09c3f
commit 99dc2d376a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -19,14 +19,24 @@ const stdinLineByLine = createInterface(process.stdin)[Symbol.asyncIterator]();
const changelog = await readFile(CHANGELOG_PATH, 'utf-8');
const commitListingStart = changelog.indexOf('\n### Commits\n');
const commitListingEnd = changelog.indexOf('\n\n<a', commitListingStart);
const commitList = changelog.slice(commitListingStart, commitListingEnd === -1 ? undefined : commitListingEnd + 1)
// Checking for semverness is too expansive, it is left as a exercice for human reviewers.
let commitList;
if (commitListingStart === -1) {
// We're preparing a semver-major release.
commitList = changelog.replace(/(^.+\n### Semver-Major|\n### Semver-(Minor|Patch)) Commits\n/gs, '')
.replaceAll('**(SEMVER-MAJOR)** ', '');
} else {
const commitListingEnd = changelog.indexOf('\n\n<a', commitListingStart);
assert.notStrictEqual(commitListingEnd, -1);
commitList = changelog.slice(commitListingStart, commitListingEnd + 1);
}
// Normalize for consistent comparison
commitList = commitList
.replaceAll('**(SEMVER-MINOR)** ', '')
// Correct Markdown escaping is validated by the linter, getting rid of it here helps.
.replaceAll('\\', '');
let expectedNumberOfCommitsLeft = commitList.match(/\n\* \[/g).length;
let expectedNumberOfCommitsLeft = commitList.match(/\n\* \[/g)?.length ?? 0;
for await (const line of stdinLineByLine) {
const { smallSha, title, prURL } = JSON.parse(line);