absolute-version / commit-and-tag-version

Fork of the excellent standard-version. Automate versioning and CHANGELOG generation, with semver.org and conventionalcommits.org :trophy:
ISC License
360 stars 33 forks source link

Bug: Frontmatter is duplicated in certain scenarios #117

Closed TimKnight-DWP closed 8 months ago

TimKnight-DWP commented 8 months ago

Describe the bug Depending on the format of the frontmatter on the CHANGELOG, commit-and-tag-version does not handle it correctly

Current behavior Frontmatter is repeatedly duplicated at the top of the CHANGELOG

image

Expected behavior Frontmatter is retained and not duplicated

Environment

Possible Solution

It'll be within the logic I added to: https://github.com/absolute-version/commit-and-tag-version/blob/master/lib/lifecycles/changelog.js#L25

Additional context Raising this bug so everyone can have insight on it, I will synch my fork and work on a fix asap

TimothyJones commented 8 months ago

Awesome, thanks for the report, and the (upcoming) fix! Much appreciated!

TimKnight-DWP commented 8 months ago

@TimothyJones something has broken the tests, in that they currently operate on the real package.json and CHANGELOG.md, so those get wiped clear at some point in the test run and everything else fails, going to try figure out what/where that has happened. And progress from there 😬

TimKnight-DWP commented 8 months ago

If I run npm run test:unit using node 18.16.0, everything works as expected If I run npm run test:unit using node 20.9.0, it all goes sideways

TimKnight-DWP commented 8 months ago

Will raise a separate issue for that

TimKnight-DWP commented 8 months ago

I cannot reproduce this bug natively using commit-and-tag-version - CLOSING may reopen if I find new data

TimKnight-DWP commented 8 months ago

For reference, this is likely coming about due to custom rules and post-event hooks within .versionrc.js on a specific repo, if it needs a specific fix here I'll come back, but suspect it's a local thing

TimKnight-DWP commented 8 months ago

Had FrontMatter defined in the "header"

 header:
    "---\nstatus: new\n---\n\n# Changelog\n\nAll notable changes to this product will be documented in this file.\n\n<!-- markdownlint-disable titlecase-rule -->",

within .versionrc.js

Which means it would have cut the FrontMatter out of the Changelog as per my code change and appended that and then the Header (containing Frontmatter as defined in versionrc), hence the duplication.

Probably a workaround prior to solving the bug fix.

No change required to commit-and-tag-version This is how the tool should work, it should respect both any Frontmatter applied and any header content in versionrc.js - shouldn't try and code for edge-cases as which to prioritise the actual front matter as extracted or whats defined in the header as they may differ