Skip to content

Commit 545f408

Browse files
committed
refactor: update changelog report
1 parent f4ca61a commit 545f408

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

lib/git/changelog.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default class GitChangelog {
2323
#previousRelease;
2424
#currentRelease;
2525
#changesGroups;
26-
#hasNotableChanges = false;
26+
#notableChanges = 0;
2727
#report;
2828

2929
constructor ( changes, { upstream, previousRelease, currentRelease, commitTypes } ) {
@@ -53,7 +53,7 @@ export default class GitChangelog {
5353
}
5454

5555
get hasNotableChanges () {
56-
return this.#hasNotableChanges;
56+
return Boolean( this.#notableChanges );
5757
}
5858

5959
get hasBreakingChanges () {
@@ -137,8 +137,13 @@ export default class GitChangelog {
137137
lines.push( [ "Total changes", this.#changes.size ] );
138138
if ( titleLength < lines.at( -1 )[ 0 ].length ) titleLength = lines.at( -1 )[ 0 ].length;
139139

140+
if ( this.#notableChanges ) {
141+
lines.push( [ "Notable changes", this.#notableChanges ] );
142+
if ( titleLength < lines.at( -1 )[ 0 ].length ) titleLength = lines.at( -1 )[ 0 ].length;
143+
}
144+
140145
for ( const group of this.#changesGroups ) {
141-
if ( !group.report && !group.changes.length ) continue;
146+
if ( !group.changes.length ) continue;
142147

143148
lines.push( [ group.name, group.changes.length ] );
144149

@@ -212,13 +217,12 @@ export default class GitChangelog {
212217

213218
// breaking change is notable
214219
if ( breakingChanges.length ) {
215-
this.#hasNotableChanges = true;
220+
this.#notableChanges++;
216221
}
217222

218223
this.#changesGroups.push( {
219224
"name": "Breaking changes",
220225
"changes": breakingChanges,
221-
"report": false,
222226
"productionChange": true,
223227
"showAnnotatiion": true,
224228
} );
@@ -229,13 +233,12 @@ export default class GitChangelog {
229233

230234
// production change is notable
231235
if ( changes.length ) {
232-
this.#hasNotableChanges = true;
236+
this.#notableChanges += changes.length;
233237
}
234238

235239
this.#changesGroups.push( {
236240
"name": title,
237241
changes,
238-
"report": false,
239242
"productionChange": true,
240243
"showAnnotatiion": true,
241244
} );
@@ -245,7 +248,6 @@ export default class GitChangelog {
245248
this.#changesGroups.push( {
246249
"name": "Other changes",
247250
"changes": this.#changes.getChanges( change => !change.isBreakingChange && !productionTypes.has( change.type ) && !change.isReleaseChange ),
248-
"report": false,
249251
"productionChange": false,
250252
"showAnnotatiion": true,
251253
} );
@@ -254,7 +256,6 @@ export default class GitChangelog {
254256
this.#changesGroups.push( {
255257
"name": "Included pre-releases",
256258
"changes": this.#changes.getChanges( change => change.isReleaseChange ),
257-
"report": false,
258259
"productionChange": false,
259260
"showAnnotatiion": false,
260261
} );

0 commit comments

Comments
 (0)