Skip to content

Commit 941d25a

Browse files
authored
Strip changelog release headers from release notes (#8)
* Strip changelog release headers from release notes * Fix some comments
1 parent 116666c commit 941d25a

3 files changed

Lines changed: 27 additions & 5 deletions

File tree

dist/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8006,7 +8006,14 @@ async function getPackageReleaseNotes(releaseVersion, repoUrl, packagePath) {
80068006
changelogContent,
80078007
repoUrl,
80088008
});
8009-
return changelog.getStringifiedRelease(releaseVersion);
8009+
// Return the stringified release without the first line, which is a markdown
8010+
// header with the release version, e.g. "## 1.0.0\n".
8011+
return (changelog
8012+
.getStringifiedRelease(releaseVersion)
8013+
// Strip the release markdown header.
8014+
.split('\n')
8015+
.slice(1)
8016+
.join('\n'));
80108017
}
80118018
//# sourceMappingURL=getReleaseNotes.js.map
80128019
;// CONCATENATED MODULE: ./lib/index.js

src/getReleaseNotes.test.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ describe('getReleaseNotes', () => {
6666
const mockRepoUrl = 'https://github.com/Org/Name';
6767
const mockVersion = '1.0.0';
6868
const mockChangelog = 'a changelog';
69-
const mockRelease = 'a mock release';
69+
const mockReleaseBody = 'a mock release';
70+
// getStringifiedRelease returns a string whose first line is a markdown
71+
// e.g. "## 1.0.0\n". This is stripped by getReleaseNotes.
72+
const mockRelease = `## Header\n${mockReleaseBody}`;
7073

7174
parseEnvVariablesMock.mockImplementationOnce(() => {
7275
return {
@@ -109,7 +112,7 @@ describe('getReleaseNotes', () => {
109112
expect(exportActionVariableMock).toHaveBeenCalledTimes(1);
110113
expect(exportActionVariableMock).toHaveBeenCalledWith(
111114
'RELEASE_NOTES',
112-
`${mockRelease}\n\n`,
115+
`${mockReleaseBody}\n\n`,
113116
);
114117
});
115118

@@ -162,7 +165,10 @@ describe('getReleaseNotes', () => {
162165
);
163166

164167
const getStringifiedReleaseMockFactory = (workspace: string) => {
165-
return (version: string) => `release ${version} for ${workspace}`;
168+
// getStringifiedRelease returns a string whose first line is a markdown
169+
// e.g. "## 1.0.0\n". This is stripped by getReleaseNotes.
170+
return (version: string) =>
171+
`## Header\nrelease ${version} for ${workspace}`;
166172
};
167173
parseChangelogMock.mockImplementation(
168174
({ changelogContent }: { changelogContent: string }) => {

src/getReleaseNotes.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,5 +138,14 @@ async function getPackageReleaseNotes(
138138
repoUrl,
139139
});
140140

141-
return changelog.getStringifiedRelease(releaseVersion);
141+
// Return the stringified release without the first line, which is a markdown
142+
// header with the release version, e.g. "## 1.0.0\n".
143+
return (
144+
changelog
145+
.getStringifiedRelease(releaseVersion)
146+
// Strip the release markdown header.
147+
.split('\n')
148+
.slice(1)
149+
.join('\n')
150+
);
142151
}

0 commit comments

Comments
 (0)