Skip to content

Commit

Permalink
fix(ng-dev): release notes not capturing multiple note keywords from …
Browse files Browse the repository at this point in the history
…single commit

Commits like the following were not captured properly because we only
assumed a single deprecation/breaking-change to be set on a commit.
  • Loading branch information
devversion committed May 4, 2022
1 parent a7d07a6 commit 01bb903
Show file tree
Hide file tree
Showing 4 changed files with 196 additions and 13 deletions.
16 changes: 14 additions & 2 deletions ng-dev/release/notes/templates/changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@ _%>
for (const group of asCommitGroups(breakingChanges)) {
_%>
### <%- group.title %>
<%- group.commits.map(commit => bulletizeText(commit.breakingChanges[0].text)).join('\\n\\n') %>
<%_
for (const commit of group.commits) {
for (const breakingChange of commit.breakingChanges) {
_%>
<%- bulletizeText(breakingChange.text) %>
<%_
}
}
}
}
_%>
Expand All @@ -35,8 +41,14 @@ _%>
for (const group of asCommitGroups(deprecations)) {
_%>
### <%- group.title %>
<%- group.commits.map(commit => bulletizeText(commit.deprecations[0].text)).join('\\n\\n') %>
<%_
for (const commit of group.commits) {
for (const deprecation of commit.deprecations) {
_%>
<%- bulletizeText(deprecation.text) %>
<%_
}
}
}
}
_%>
Expand Down
16 changes: 14 additions & 2 deletions ng-dev/release/notes/templates/github-release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@ _%>
for (const group of asCommitGroups(breakingChanges)) {
_%>
### <%- group.title %>
<%- group.commits.map(commit => bulletizeText(commit.breakingChanges[0].text)).join('\\n\\n') %>
<%_
for (const commit of group.commits) {
for (const breakingChange of commit.breakingChanges) {
_%>
<%- bulletizeText(breakingChange.text) %>
<%_
}
}
}
}
_%>
Expand All @@ -35,8 +41,14 @@ _%>
for (const group of asCommitGroups(deprecations)) {
_%>
### <%- group.title %>
<%- group.commits.map(commit => bulletizeText(commit.deprecations[0].text)).join('\\n\\n') %>
<%_
for (const commit of group.commits) {
for (const deprecation of commit.deprecations) {
_%>
<%- bulletizeText(deprecation.text) %>
<%_
}
}
}
}
_%>
Expand Down
145 changes: 140 additions & 5 deletions ng-dev/release/publish/test/release-notes/generation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@
* found in the LICENSE file at https://angular.io/license
*/

import {prepareTempDirectory} from '../test-utils/action-mocks';
import * as config from '../../../../utils/config';
import {ReleaseNotes} from '../../../notes/release-notes';
import {
getMockGitClient,
installSandboxGitClient,
SandboxGitClient,
SandboxGitRepo,
} from '../../../../utils/testing';
import {ReleaseConfig} from '../../../config';
import {ReleaseNotes} from '../../../notes/release-notes';
import {prepareTempDirectory} from '../test-utils/action-mocks';
import {changelogPattern, parse} from '../test-utils/test-utils';
import {installSandboxGitClient, SandboxGitClient} from '../../../../utils/testing';
import {getMockGitClient} from '../../../../utils/testing';
import {SandboxGitRepo} from '../../../../utils/testing';

describe('release notes generation', () => {
let releaseConfig: ReleaseConfig;
Expand Down Expand Up @@ -239,6 +242,39 @@ describe('release notes generation', () => {
`);
});

it('should capture multiple breaking changes from a single commit', async () => {
SandboxGitRepo.withInitialCommit(githubConfig)
.commit('fix(cdk/a11y): already released *1')
.createTagForHead('13.0.0-next.0')
.commit('fix(cdk/a11y): not yet released *1')
.commit(
'refactor(cdk/a11y): with breaking change\n\n' +
'BREAKING CHANGE: Description of breaking change.\n\n' +
'BREAKING CHANGE: Description of breaking change 2.',
);

const releaseNotes = await ReleaseNotes.forRange(
client,
parse('13.0.0'),
'13.0.0-next.0',
'HEAD',
);

expect(await releaseNotes.getChangelogEntry()).toMatch(changelogPattern`
# 13.0.0 <..>
## Breaking Changes
### cdk/a11y
- Description of breaking change.
- Description of breaking change 2.
### cdk/a11y
| Commit | Type | Description |
| -- | -- | -- |
| <..> | fix | not yet released *1 |
| <..> | refactor | with breaking change |
## Special Thanks
`);
});

it('should indent breaking changes with bullets', async () => {
SandboxGitRepo.withInitialCommit(githubConfig)
.commit('fix(cdk/a11y): already released *1')
Expand Down Expand Up @@ -304,6 +340,39 @@ describe('release notes generation', () => {
## Special Thanks
`);
});

it('should capture multiple deprecations from a single commit', async () => {
SandboxGitRepo.withInitialCommit(githubConfig)
.commit('fix(cdk/a11y): already released *1')
.createTagForHead('13.0.0-next.0')
.commit('fix(cdk/a11y): not yet released *1')
.commit(
'refactor(cdk/a11y): with deprecation\n\n' +
'DEPRECATED: Description of deprecation.\n\n' +
'DEPRECATED: Description of deprecation 2.',
);

const releaseNotes = await ReleaseNotes.forRange(
client,
parse('13.0.0'),
'13.0.0-next.0',
'HEAD',
);

expect(await releaseNotes.getChangelogEntry()).toMatch(changelogPattern`
# 13.0.0 <..>
## Deprecations
### cdk/a11y
- Description of deprecation.
- Description of deprecation 2.
### cdk/a11y
| Commit | Type | Description |
| -- | -- | -- |
| <..> | fix | not yet released *1 |
| <..> | refactor | with deprecation |
## Special Thanks
`);
});
});

describe('github release notes', () => {
Expand Down Expand Up @@ -489,6 +558,39 @@ describe('release notes generation', () => {
`);
});

it('should capture multiple breaking changes from a single commit', async () => {
SandboxGitRepo.withInitialCommit(githubConfig)
.commit('fix(cdk/a11y): already released *1')
.createTagForHead('13.0.0-next.0')
.commit('fix(cdk/a11y): not yet released *1')
.commit(
'refactor(cdk/a11y): with breaking change\n\n' +
'BREAKING CHANGE: Description of breaking change.\n\n' +
'BREAKING CHANGE: Description of breaking change 2.',
);

const releaseNotes = await ReleaseNotes.forRange(
client,
parse('13.0.0'),
'13.0.0-next.0',
'HEAD',
);

expect(await releaseNotes.getGithubReleaseEntry()).toMatch(changelogPattern`
# 13.0.0 <..>
## Breaking Changes
### cdk/a11y
- Description of breaking change.
- Description of breaking change 2.
### cdk/a11y
| Commit | Description |
| -- | -- |
| <..> | not yet released *1 |
| <..> | with breaking change |
## Special Thanks
`);
});

it('should capture deprecations', async () => {
SandboxGitRepo.withInitialCommit(githubConfig)
.commit('fix(cdk/a11y): already released *1')
Expand Down Expand Up @@ -520,6 +622,39 @@ describe('release notes generation', () => {
});
});

it('should capture multiple deprecations from a single commit', async () => {
SandboxGitRepo.withInitialCommit(githubConfig)
.commit('fix(cdk/a11y): already released *1')
.createTagForHead('13.0.0-next.0')
.commit('fix(cdk/a11y): not yet released *1')
.commit(
'refactor(cdk/a11y): with deprecation\n\n' +
'DEPRECATED: Description of deprecation.\n\n' +
'DEPRECATED: Description of deprecation 2.',
);

const releaseNotes = await ReleaseNotes.forRange(
client,
parse('13.0.0'),
'13.0.0-next.0',
'HEAD',
);

expect(await releaseNotes.getGithubReleaseEntry()).toMatch(changelogPattern`
# 13.0.0 <..>
## Deprecations
### cdk/a11y
- Description of deprecation.
- Description of deprecation 2.
### cdk/a11y
| Commit | Description |
| -- | -- |
| <..> | not yet released *1 |
| <..> | with deprecation |
## Special Thanks
`);
});

it('should determine the number of commits included in the entry', async () => {
SandboxGitRepo.withInitialCommit(githubConfig)
.createTagForHead('0.0.0')
Expand Down
32 changes: 28 additions & 4 deletions tools/local-actions/changelog/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -48384,8 +48384,14 @@ _%>
for (const group of asCommitGroups(breakingChanges)) {
_%>
### <%- group.title %>
<%- group.commits.map(commit => bulletizeText(commit.breakingChanges[0].text)).join('\\n\\n') %>
<%_
for (const commit of group.commits) {
for (const breakingChange of commit.breakingChanges) {
_%>
<%- bulletizeText(breakingChange.text) %>
<%_
}
}
}
}
_%>
Expand All @@ -48399,8 +48405,14 @@ _%>
for (const group of asCommitGroups(deprecations)) {
_%>
### <%- group.title %>
<%- group.commits.map(commit => bulletizeText(commit.deprecations[0].text)).join('\\n\\n') %>
<%_
for (const commit of group.commits) {
for (const deprecation of commit.deprecations) {
_%>
<%- bulletizeText(deprecation.text) %>
<%_
}
}
}
}
_%>
Expand Down Expand Up @@ -48462,8 +48474,14 @@ _%>
for (const group of asCommitGroups(breakingChanges)) {
_%>
### <%- group.title %>
<%- group.commits.map(commit => bulletizeText(commit.breakingChanges[0].text)).join('\\n\\n') %>
<%_
for (const commit of group.commits) {
for (const breakingChange of commit.breakingChanges) {
_%>
<%- bulletizeText(breakingChange.text) %>
<%_
}
}
}
}
_%>
Expand All @@ -48477,8 +48495,14 @@ _%>
for (const group of asCommitGroups(deprecations)) {
_%>
### <%- group.title %>
<%- group.commits.map(commit => bulletizeText(commit.deprecations[0].text)).join('\\n\\n') %>
<%_
for (const commit of group.commits) {
for (const deprecation of commit.deprecations) {
_%>
<%- bulletizeText(deprecation.text) %>
<%_
}
}
}
}
_%>
Expand Down

0 comments on commit 01bb903

Please sign in to comment.