diff --git a/core/conventional-commits/__tests__/conventional-commits.test.js b/core/conventional-commits/__tests__/conventional-commits.test.js index 0c7cfe669c..60c8e09117 100644 --- a/core/conventional-commits/__tests__/conventional-commits.test.js +++ b/core/conventional-commits/__tests__/conventional-commits.test.js @@ -377,7 +377,7 @@ describe("conventional-commits", () => { ]); expect(leafChangelog.newEntry.trimRight()).toMatchInlineSnapshot(` -## [1.0.1](/compare/dragons-are-awesome1.0.0...1.0.1) (YYYY-MM-DD) +## [1.0.1](/compare/dragons-are-awesome1.0.0...dragons-are-awesome1.0.1) (YYYY-MM-DD) ### Bug Fixes @@ -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](/compare/dragons-are-awesome1.0.0...1.0.1) (YYYY-MM-DD) +## [1.0.1](/compare/dragons-are-awesome1.0.0...dragons-are-awesome1.0.1) (YYYY-MM-DD) ### Bug Fixes @@ -409,7 +409,7 @@ describe("conventional-commits", () => { // second commit should not show up again expect(lastRootChangelog.newEntry.trimRight()).toMatchInlineSnapshot(` -## [1.0.2](/compare/dragons-are-awesome1.0.1...1.0.2) (YYYY-MM-DD) +## [1.0.2](/compare/dragons-are-awesome1.0.1...dragons-are-awesome1.0.2) (YYYY-MM-DD) ### Bug Fixes diff --git a/core/conventional-commits/lib/update-changelog.js b/core/conventional-commits/lib/update-changelog.js index 12a4824280..e62a33217a 100644 --- a/core/conventional-commits/lib/update-changelog.js +++ b/core/conventional-commits/lib/update-changelog.js @@ -11,12 +11,12 @@ const readExistingChangelog = require("./read-existing-changelog"); module.exports = updateChangelog; -function updateChangelog(pkg, type, { changelogPreset, rootPath, tagPrefix, version }) { +function updateChangelog(pkg, type, { changelogPreset, rootPath, tagPrefix = "v", version }) { log.silly(type, "for %s at %s", pkg.name, pkg.location); return getChangelogConfig(changelogPreset, rootPath).then(config => { const options = {}; - let context; // pass as positional because cc-core's merge-config is wack + const context = {}; // pass as positional because cc-core's merge-config is wack // cc-core mutates input :P if (config.conventionalChangelog) { @@ -31,7 +31,10 @@ function updateChangelog(pkg, type, { changelogPreset, rootPath, tagPrefix, vers const gitRawCommitsOpts = Object.assign({}, options.config.gitRawCommitsOpts); if (type === "root") { - context = { version }; + context.version = version; + + // preserve tagPrefix because cc-core can't find the currentTag otherwise + context.currentTag = `${tagPrefix}${version}`; // root changelogs are only enabled in fixed mode, and need the proper tag prefix options.tagPrefix = tagPrefix; @@ -45,6 +48,9 @@ function updateChangelog(pkg, type, { changelogPreset, rootPath, tagPrefix, vers } else { // only fixed mode can have a custom tag prefix options.tagPrefix = tagPrefix; + + // preserve tagPrefix because cc-core can't find the currentTag otherwise + context.currentTag = `${tagPrefix}${pkg.version}`; } }