@@ -82,6 +82,11 @@ function section(areas: Set<string>) {
8282 return "Core"
8383}
8484
85+ function type ( message : string ) {
86+ if ( message . match ( / f i x / i) ) return "Bugfixes"
87+ return "Improvements"
88+ }
89+
8590function reverted ( commits : Commit [ ] ) {
8691 const seen = new Map < string , Commit > ( )
8792
@@ -193,13 +198,20 @@ async function thanks(from: string, to: string, reuse: boolean) {
193198}
194199
195200function format ( from : string , to : string , list : Commit [ ] , thanks : string [ ] ) {
196- const grouped = new Map < string , string [ ] > ( )
197- for ( const title of order ) grouped . set ( title , [ ] )
201+ const grouped = new Map < string , Map < string , string [ ] > > ( )
202+ for ( const title of order ) {
203+ grouped . set (
204+ title ,
205+ new Map ( [
206+ [ "Improvements" , [ ] ] ,
207+ [ "Bugfixes" , [ ] ] ,
208+ ] ) ,
209+ )
210+ }
198211
199212 for ( const commit of list ) {
200- const title = section ( commit . areas )
201213 const attr = commit . author && ! team . includes ( commit . author ) ? ` (@${ commit . author } )` : ""
202- grouped . get ( title ) ! . push ( `- \`${ commit . hash } \` ${ commit . message } ${ attr } ` )
214+ grouped . get ( section ( commit . areas ) ) ! . get ( type ( commit . message ) ) ! . push ( `- \`${ commit . hash } \` ${ commit . message } ${ attr } ` )
203215 }
204216
205217 const lines = [ `Last release: ${ ref ( from ) } ` , `Target ref: ${ to } ` , "" ]
@@ -209,11 +221,23 @@ function format(from: string, to: string, list: Commit[], thanks: string[]) {
209221 }
210222
211223 for ( const title of order ) {
212- const entries = grouped . get ( title )
213- if ( ! entries || entries . length === 0 ) continue
224+ const groups = grouped . get ( title )
225+ if ( ! groups || [ ... groups . values ( ) ] . every ( ( entries ) => entries . length === 0 ) ) continue
214226 lines . push ( `## ${ title } ` )
215- lines . push ( ...entries )
216- lines . push ( "" )
227+ const improvements = groups . get ( "Improvements" ) !
228+ const bugfixes = groups . get ( "Bugfixes" ) !
229+ if ( bugfixes . length === 0 ) {
230+ lines . push ( ...improvements )
231+ lines . push ( "" )
232+ continue
233+ }
234+
235+ for ( const [ subtitle , entries ] of groups ) {
236+ if ( entries . length === 0 ) continue
237+ lines . push ( `### ${ subtitle } ` )
238+ lines . push ( ...entries )
239+ lines . push ( "" )
240+ }
217241 }
218242
219243 if ( thanks . length > 0 ) {
0 commit comments