@@ -18,15 +18,34 @@ import { createInterface } from 'node:readline';
1818const stdinLineByLine = createInterface ( process . stdin ) [ Symbol . asyncIterator ] ( ) ;
1919
2020const changelog = await readFile ( CHANGELOG_PATH , 'utf-8' ) ;
21- const commitListingStart = changelog . indexOf ( '\n### Commits\n' ) ;
22- const commitListingEnd = changelog . indexOf ( '\n\n<a' , commitListingStart ) ;
23- const commitList = changelog . slice ( commitListingStart , commitListingEnd === - 1 ? undefined : commitListingEnd + 1 )
24- // Checking for semverness is too expansive, it is left as a exercice for human reviewers.
21+ const sectionTitles = [
22+ '### Commits' ,
23+ '### Semver-Major Commits' ,
24+ '### Semver-Minor Commits' ,
25+ '### Semver-Patch Commits'
26+ ] ;
27+
28+ let commitList = '' ;
29+
30+ for ( const title of sectionTitles ) {
31+ const start = changelog . indexOf ( `\n${ title } \n` ) ;
32+ if ( start === - 1 ) continue ;
33+
34+ const end = changelog . indexOf ( '\n\n' , start + 1 ) ;
35+ const section = changelog . slice ( start , end === - 1 ? undefined : end + 1 ) ;
36+ commitList += section ;
37+ }
38+
39+ assert ( commitList , 'No recognized commit section found in changelog' ) ;
40+
41+ // Normalize for consistent comparison
42+ commitList = commitList
2543 . replaceAll ( '**(SEMVER-MINOR)** ' , '' )
26- // Correct Markdown escaping is validated by the linter, getting rid of it here helps.
44+ . replaceAll ( '**(SEMVER-MAJOR)** ' , '' )
2745 . replaceAll ( '\\' , '' ) ;
2846
29- let expectedNumberOfCommitsLeft = commitList . match ( / \n \* \[ / g) . length ;
47+ let expectedNumberOfCommitsLeft = ( commitList . match ( / \n \* \[ / g) || [ ] ) . length ;
48+
3049for await ( const line of stdinLineByLine ) {
3150 const { smallSha, title, prURL } = JSON . parse ( line ) ;
3251
0 commit comments