From 8adeac18ac4bcecf3d333fd80de9734c4f245636 Mon Sep 17 00:00:00 2001 From: Daniel Stockman Date: Tue, 23 Jul 2019 17:12:55 -0700 Subject: [PATCH] fix(conventional-commits): Avoid duplicate root changelog entries with custom `--tag-version-prefix` Fixes #2197 --- .../__tests__/conventional-commits.test.js | 5 ++--- core/conventional-commits/lib/update-changelog.js | 3 +++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/conventional-commits/__tests__/conventional-commits.test.js b/core/conventional-commits/__tests__/conventional-commits.test.js index 2a41808781..0c7cfe669c 100644 --- a/core/conventional-commits/__tests__/conventional-commits.test.js +++ b/core/conventional-commits/__tests__/conventional-commits.test.js @@ -385,7 +385,7 @@ describe("conventional-commits", () => { * A second commit for our CHANGELOG ([SHA](https://github.com/lerna/conventional-commits-fixed/commit/SHA)) `); expect(rootChangelog.newEntry.trimRight()).toMatchInlineSnapshot(` -## 1.0.1 (YYYY-MM-DD) +## [1.0.1](/compare/dragons-are-awesome1.0.0...1.0.1) (YYYY-MM-DD) ### Bug Fixes @@ -409,12 +409,11 @@ describe("conventional-commits", () => { // second commit should not show up again expect(lastRootChangelog.newEntry.trimRight()).toMatchInlineSnapshot(` -## 1.0.2 (YYYY-MM-DD) +## [1.0.2](/compare/dragons-are-awesome1.0.1...1.0.2) (YYYY-MM-DD) ### Bug Fixes -* A second commit for our CHANGELOG ([SHA](https://github.com/lerna/conventional-commits-fixed/commit/SHA)) * A third commit for our CHANGELOG ([SHA](https://github.com/lerna/conventional-commits-fixed/commit/SHA)) `); }); diff --git a/core/conventional-commits/lib/update-changelog.js b/core/conventional-commits/lib/update-changelog.js index a56375a1ad..12a4824280 100644 --- a/core/conventional-commits/lib/update-changelog.js +++ b/core/conventional-commits/lib/update-changelog.js @@ -32,6 +32,9 @@ function updateChangelog(pkg, type, { changelogPreset, rootPath, tagPrefix, vers if (type === "root") { context = { version }; + + // root changelogs are only enabled in fixed mode, and need the proper tag prefix + options.tagPrefix = tagPrefix; } else { // "fixed" or "independent" gitRawCommitsOpts.path = pkg.location;