Closed k2snowman69 closed 2 years ago
Fiddling around, I think the fix is something like this:
getChangelog(latestVersion) {
const { isIncrement } = this.config;
// Return the unchanged changelog content when no increment is made
if (!isIncrement) {
return this.getLatestVersionLog(latestVersion);
}
// ... all this stays the same though you might want to pull it out into it's own function
// for symmetry with getLatestVersionLog such as getUnreleasedVersionLog
}
getLatestVersionLog(latestVersion) {
const latestVersionTitle = `## [${latestVersion}]`;
const hasLatestVersionSection = this.changelogContent.includes(latestVersionTitle);
if (!hasLatestVersionSection) {
throw Error(`Missing section for previous release ("${latestVersion}") in ${filename}.`);
}
const titleStart = this.changelogContent.indexOf(latestVersionTitle);
const contentStart = this.changelogContent.indexOf(this.EOL, titleStart) + 1;
const nextTitle = `## [`;
let endIndex = this.changelogContent.indexOf(nextTitle, contentStart);
if (endIndex === -1) {
endIndex = this.changelogContent.length;
}
const changelogContent = this.changelogContent.substring(contentStart, endIndex).trim();
if (!changelogContent) {
throw Error(`There are no entries under "${latestVersionTitle}" section in ${filename}.`);
}
this.setContext({ changelog: changelogContent });
return changelogContent;
}
Sorry for the tag @webpro however I'm just wanting to know if this is a fix you're interested in taking? This is the last piece I needed before migrating my workflows to release-it so I'm a bit excited and wanting to close this out.
Sorry for the late reply, not sure why I missed it.
But yes! Would be a great addition/fix to have in this plugin. Happy to review and merge your PR.
Currently when running using the
--no-increment
flag, the entire changelog is provided:This coupled with git.release=true means the github release's content contains the entire changelog.
Expected
Only the content for the latest version to be included in the release content
Actual
Entire content of the changelog is contained in the release information