Skip to content

Commit

Permalink
feat(publisher): match first changelog entry (projen#1750)
Browse files Browse the repository at this point in the history
The first ever changelog entry created by standard-version
doesn't link to a diff because none exists yet. For that
reason there are no markdown link brackets around the
version, which was causing the first manual release to
fail.

Closes projen#1749

---
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
  • Loading branch information
gradybarrett authored Apr 11, 2022
1 parent 5f1dd9b commit 09cf63e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/release/update-changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export async function updateChangelog(
}

const inputChangelogContent = await readFile(inputChangelog, "utf-8");
const changelogVersionSearchPattern = `[${version}]`;
const changelogVersionSearchPattern = `${version}`;

if (!inputChangelogContent.includes(changelogVersionSearchPattern)) {
throw new Error(
Expand Down
11 changes: 11 additions & 0 deletions test/release/update-changelog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ test("adds a new changelog if missing", async () => {
expect(result.projectChangelogContent.length).toBeGreaterThan(0);
});

test("matches first changelog entry missing brackets around the version", async () => {
const result = await testUpdateChangelog({
testOptions: {
inputChangelogContent: `## ${DEFAULT_VERSION} (2021-09-04)`,
},
});

expect(result.commits[0]).toMatch(`chore(release): ${DEFAULT_VERSION}`);
expect(result.lastCommitContent).toMatch(/.*CHANGELOG\.md.*/g);
});

test("duplicate release tag update is idempotent", async () => {
const result1 = await testUpdateChangelog();
const result2 = await testUpdateChangelog({
Expand Down

0 comments on commit 09cf63e

Please sign in to comment.