Skip to content

Commit 6c2b3ee

Browse files
fix(release): ensure emoji is not repeated in breaking changes summary (#33605)
## Current Behavior The ⚠️ emoji at the beginning of bc commits is duplicated in the bc section of the changelog. This is unneeded. ## Expected Behavior Ensure the ⚠️ is not repeated in the bc section of the changelog --------- Co-authored-by: nx-cloud[bot] <71083854+nx-cloud[bot]@users.noreply.github.com> Co-authored-by: Coly010 <[email protected]>
1 parent d70c888 commit 6c2b3ee

4 files changed

Lines changed: 27 additions & 25 deletions

File tree

e2e/release/src/conventional-commits-config.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ describe('nx release conventional commits config', () => {
399399
400400
### ⚠️ Breaking Changes
401401
402-
- ⚠️ **{project-name}:** this is a breaking change
402+
- **{project-name}:** this is a breaking change
403403
`);
404404

405405
const pkg2Changelog = readFile(`${pkg2}/CHANGELOG.md`);

e2e/release/src/conventional-commits-config.workspaces.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ describe('nx release conventional commits config', () => {
406406
407407
### ⚠️ Breaking Changes
408408
409-
- ⚠️ **{project-name}:** this is a breaking change
409+
- **{project-name}:** this is a breaking change
410410
`);
411411

412412
const pkg2Changelog = readFile(`${pkg2}/CHANGELOG.md`);

packages/nx/release/changelog-renderer/index.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -708,20 +708,20 @@ describe('ChangelogRenderer', () => {
708708
}).render();
709709

710710
expect(markdown).toMatchInlineSnapshot(`
711-
"## v1.1.0
711+
"## v1.1.0
712712
713-
### 🚀 Features
713+
### 🚀 Features
714714
715-
- ⚠️ **WebSocketSubject:** no longer extends \`Subject\`.
715+
- ⚠️ **WebSocketSubject:** no longer extends \`Subject\`.
716716
717-
### ⚠️ Breaking Changes
717+
### ⚠️ Breaking Changes
718718
719-
- ⚠️ **WebSocketSubject:** no longer extends \`Subject\`.
719+
- **WebSocketSubject:** no longer extends \`Subject\`.
720720
721-
### ❤️ Thank You
721+
### ❤️ Thank You
722722
723-
- James Henry"
724-
`);
723+
- James Henry"
724+
`);
725725
});
726726

727727
it('should extract the explanation of a breaking change and render it preferentially with references', async () => {

packages/nx/release/changelog-renderer/index.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -408,42 +408,44 @@ export default class DefaultChangelogRenderer {
408408
return changeLine;
409409
}
410410

411-
protected formatBreakingChange(change: ChangelogChange): string {
412-
const explanation = this.extractBreakingChangeExplanation(change.body);
413-
414-
if (!explanation) {
415-
// No explanation found, use the regular formatChange which includes references
416-
return this.formatChange(change);
417-
}
418-
419-
// Build the breaking change line with scope, explanation, and references
411+
protected formatBreakingChangeBase(change: ChangelogChange): string {
420412
let breakingLine = '- ';
421413

422414
if (change.scope) {
423415
breakingLine += `**${change.scope.trim()}:** `;
424416
}
425-
// Ensure first line of the breaking change contains the commit title
417+
426418
if (change.description) {
427-
breakingLine += `${change.description.trim()} `;
419+
breakingLine += `${change.description.trim()}`;
428420
}
429421

430-
// Add PR/commit references
431422
if (
432423
this.remoteReleaseClient.getRemoteRepoData() &&
433424
this.changelogRenderOptions.commitReferences &&
434425
change.githubReferences
435426
) {
436-
breakingLine += `${this.remoteReleaseClient.formatReferences(
427+
breakingLine += ` ${this.remoteReleaseClient.formatReferences(
437428
change.githubReferences
438429
)}`;
439430
}
440431

432+
return breakingLine;
433+
}
434+
435+
protected formatBreakingChange(change: ChangelogChange): string {
436+
const explanation = this.extractBreakingChangeExplanation(change.body);
437+
const baseLine = this.formatBreakingChangeBase(change);
438+
439+
if (!explanation) {
440+
return baseLine;
441+
}
442+
441443
const indentation = ' ';
442-
breakingLine += `\n${indentation}`;
444+
let breakingLine = baseLine + `\n${indentation}`;
443445

444446
// Handle multi-line explanations
445447
let explanationText = explanation;
446-
let extraLines = [];
448+
let extraLines: string[] = [];
447449
if (explanation.includes('\n')) {
448450
[explanationText, ...extraLines] = explanation.split('\n');
449451
}

0 commit comments

Comments
 (0)