Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing separator (newline) when prepending content in changelog file #46

Closed
alex-fournier opened this issue Apr 5, 2022 · 4 comments
Closed

Comments

@alex-fournier
Copy link

Hello !

Since v4.2.0, there is no more newline between the newly prepended changelog and the previous changelog, resulting to something like this:

* last line ([1a2b3c](https://gitlab.com/.../commit/1a2b3c))## [1.4.0](https://gitlab.com/.../compare/1.3.1...1.4.0) (2022-04-05)

Here is my plugins config in .release-it.json:

{
  "plugins": {
    "@release-it/conventional-changelog": {
      "ignoreRecommendedBump": true,
      "infile": "CHANGELOG.md",
      "preset": {
        "name": "conventionalcommits",
        "issueUrlFormat": "https://gitlab.com/{{id}}",
        "types": [
          { "type": "feat", "section": "Features" },
          { "type": "fix", "section": "Bug Fixes" },
          { "type": "chore", "section": "Chore" },
          { "type": "build", "hidden": true },
          {}
        ]
      }
    }
  }
}
@thet
Copy link
Contributor

thet commented Apr 8, 2022

same here

thet added a commit to Patternslib/Patterns that referenced this issue Apr 8, 2022
Since conventional-changelog 4.2.0 the previous header is merged to the
end of the new changelog entry block.
This is documented here: release-it/conventional-changelog#46
As long as this issue is not resolved, we're adding a ``#`` at the end
of the changelog block, intending the previous entry in the heading
hierarchy, but that's better than a even more messed up changelog file.
@thet
Copy link
Contributor

thet commented Apr 8, 2022

If you want to stay on 4.2.0, this could be a quickfix - basically I add a hash sign # at the very end of the header-template.hbs which will prepended to the previous header and intends it for one level.

.release-it.js:

const fs = require("fs");
const path = require("path");

const main_template = fs
    .readFileSync(
        path.resolve(__dirname, "header-template.hbs")
    )
    .toString();

module.exports = {
    npm: {
        publish: true,
    },
    git: {
        requireBranch: "master",
        commitMessage: "Release new version.",
        commitArgs: ["-n"],
    },
    plugins: {
        "@release-it/conventional-changelog": {
            infile: "CHANGES.md",
            ignoreRecommendedBump: true,
            preset: {
                name: "conventionalcommits",
                types: [
                    {
                        type: "breaking",
                        section: "Breaking Changes",
                    },
                    {
                        type: "feat",
                        section: "Features",
                    },
                    {
                        type: "fix",
                        section: "Bug Fixes",
                    },
                    {
                        type: "maint",
                        section: "Maintenance",
                    },
                ],
            },
            writerOpts: {
                mainTemplate: main_template,
            },
        },
    },
};

header-template.hbs:

{{> header}}

{{#if noteGroups}}
{{#each noteGroups}}

### ⚠ {{title}}

{{#each notes}}
* {{#if commit.scope}}**{{commit.scope}}:** {{/if}}{{text}}
{{/each}}
{{/each}}
{{/if}}
{{#each commitGroups}}

{{#if title}}
### {{title}}

{{/if}}
{{#each commits}}
{{> commit root=@root}}
{{/each}}

{{/each}}

#

Note the # sign just above.
This does intend the previous changelog header entry at one level, which is currently acceptable for me.

@webpro
Copy link
Contributor

webpro commented Apr 15, 2022

Hopefully it's fixed in v4.3.0, can you please confirm

@thet
Copy link
Contributor

thet commented Apr 15, 2022

@webpro I can confirm, it works!
Thanks for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants