Skip to content

Commit d31e630

Browse files
aduh95RafaelGSS
andcommitted
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: #57892 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
1 parent 99ed503 commit d31e630

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

‎tools/actions/lint-release-proposal-commit-list.mjs‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,24 @@ const stdinLineByLine = createInterface(process.stdin)[Symbol.asyncIterator]();
1919

2020
constchangelog=awaitreadFile(CHANGELOG_PATH,'utf-8');
2121
constcommitListingStart=changelog.indexOf('\n### Commits\n');
22-
constcommitListingEnd=changelog.indexOf('\n\n<a',commitListingStart);
23-
constcommitList=changelog.slice(commitListingStart,commitListingEnd===-1 ? undefined : commitListingEnd+1)
24-
// Checking for semverness is too expansive, it is left as a exercice for human reviewers.
22+
letcommitList;
23+
if(commitListingStart===-1){
24+
// We're preparing a semver-major release.
25+
commitList=changelog.replace(/(^.+\n###Semver-Major|\n###Semver-(Minor|Patch))Commits\n/gs,'')
26+
.replaceAll('**(SEMVER-MAJOR)** ','');
27+
}else{
28+
constcommitListingEnd=changelog.indexOf('\n\n<a',commitListingStart);
29+
assert.notStrictEqual(commitListingEnd,-1);
30+
commitList=changelog.slice(commitListingStart,commitListingEnd+1);
31+
}
32+
33+
// Normalize for consistent comparison
34+
commitList=commitList
2535
.replaceAll('**(SEMVER-MINOR)** ','')
26-
// Correct Markdown escaping is validated by the linter, getting rid of it here helps.
2736
.replaceAll('\\','');
2837

29-
letexpectedNumberOfCommitsLeft=commitList.match(/\n\*\[/g).length;
38+
letexpectedNumberOfCommitsLeft=commitList.match(/\n\*\[/g)?.length??0;
39+
3040
forawait(constlineofstdinLineByLine){
3141
const{ smallSha, title, prURL }=JSON.parse(line);
3242

0 commit comments

Comments
 (0)