Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const extractChangelogEntry: typeof extractChangelogEntryDef = ({
}) => {
const sections = fs.readFileSync(changelogPath, "utf-8").split(/^## /m).slice(1);
const section = sections.find((candidate) => {
const heading = candidate.split("\n", 1)[0];
const heading = candidate.split("\n", 1)[0].replace(/^<small>/, "");
return heading.includes(`[${version}](`) || heading.startsWith(`${version} (`);
});
if (!section) throw new Error(`Missing changelog entry for ${version}`);
Expand Down
21 changes: 21 additions & 0 deletions tests/changelog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,27 @@ describe("extractChangelogEntry", () => {
* add a feature`);
});

for (const heading of [
"<small>0.0.1 (2026-11-26)</small>",
"<small>[0.0.1](https://example.com/compare/v0.0.0...v0.0.1) (2026-11-26)</small>",
]) {
it(`extracts a changelog entry with heading ${heading}`, async () => {
const entry = `### Features

* init ([3007710](https://github.com/vitejs/deployment-metadata/commit/3007710e91658f57dbce9bf5a16eb657da64a6a8))
* make \`DeploymentMetadata\` the union of all metadata types ([#16](https://github.com/vitejs/deployment-metadata/issues/16)) ([3c4426e](https://github.com/vitejs/deployment-metadata/commit/3c4426e2b7703b80dc3f46464a64e223b3b38a09))`;
const changelogPath = await createChangelog(`## ${heading}
${entry}

## 0.0.0 (2026-11-25)

* older change
`);

expect(extractChangelogEntry({ changelogPath, version: "0.0.1" })).toBe(entry);
});
}

// plugin-react, plugin-react-swc
it("extracts a manually maintained changelog entry", async () => {
const changelogPath = await createChangelog(`## Unreleased
Expand Down