Skip to content

Commit

Permalink
Fix rewrite for entries with a summary (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeddy3 authored Jan 12, 2025
1 parent 43399bd commit 880618b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
10 changes: 6 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50338,10 +50338,12 @@ function extractChangeItems({ version }) {
parent &&
index !== undefined
) {
const nextSibling = parent.children[index + 1];
if (nextSibling?.type === 'list') {
list = nextSibling;
return EXIT;
const nextSiblings = parent.children.slice(index + 1);
for (const sibling of nextSiblings) {
if (sibling.type === 'list') {
list = sibling;
return EXIT;
}
}
}
return CONTINUE;
Expand Down
14 changes: 14 additions & 0 deletions src/__tests__/changelogToGithubRelease.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ import { changelogToGithubRelease } from '../changelogToGithubRelease.js';
const changelog = `
# Changelog
## 16.13.0 - 2025-01-12
Summary.
Summary 2.
- fff [#123](https://github.com/foo/bar/pull/123) ([@user](https://github.com/user)).
- ggg.
## 1.2.0
- reference-style link [#456][] ([@user1]).
Expand All @@ -29,6 +38,11 @@ test('rewrite change items including reference links', { only: true }, async ()
assert.equal(result, '* reference-style link #456 (@user1).\n');
});

test('rewrite change items for version with date in heading and a summary', async () => {
const result = await changelogToGithubRelease(changelog, '16.13.0');
assert.equal(result, '* fff #123 (@user).\n* ggg.\n');
});

test('rewrite change items for version with date in heading', async () => {
const result = await changelogToGithubRelease(changelog, '1.1.0');
assert.equal(result, '* ddd #123 (@user).\n* eee.\n');
Expand Down
10 changes: 6 additions & 4 deletions src/changelogToGithubRelease.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ function extractChangeItems({ version }) {
parent &&
index !== undefined
) {
const nextSibling = parent.children[index + 1];
if (nextSibling?.type === 'list') {
list = nextSibling;
return EXIT;
const nextSiblings = parent.children.slice(index + 1);
for (const sibling of nextSiblings) {
if (sibling.type === 'list') {
list = sibling;
return EXIT;
}
}
}
return CONTINUE;
Expand Down

0 comments on commit 880618b

Please sign in to comment.