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

tagPrefix not working #80

Open
jordanrastrick opened this issue Jan 3, 2024 · 1 comment
Open

tagPrefix not working #80

jordanrastrick opened this issue Jan 3, 2024 · 1 comment

Comments

@jordanrastrick
Copy link

I have the following .release-it.json:

{
  "plugins": {
    "@release-it/conventional-changelog": {
      "path": ".",
      "infile": "CHANGELOG.md",
      "gitRawCommitsOpts": {
        "path": "."
      },
      "preset": {
        "name": "conventionalcommits",
        "types": [
          {
            "type": "feat",
            "section": "Features"
          },
          {
            "type": "fix",
            "section": "Bug Fixes"
          },
          {
            "type": "perf",
            "section": "Performance Improvements"
          },
          {
            "type": "revert",
            "section": "Reverts"
          },
          {
            "type": "docs",
            "section": "Documentation"
          },
          {
            "type": "style",
            "section": "Styles",
            "hidden": true
          },
          {
            "type": "chore",
            "section": "Miscellaneous Chores"
          },
          {
            "type": "ref",
            "section": "Code Refactoring"
          },
          {
            "type": "test",
            "section": "Tests"
          },
          {
            "type": "build",
            "section": "Build System"
          },
          {
            "type": "ci",
            "section": "Continuous Integration"
          }
        ]
      }
    }
  },
  "github": {
    "release": true,
    "releaseName": "${npm.name}@${version}",
    "proxy": [...]
  },
  "git": {
    "tagName": "${npm.name}@${version}",
    "commitMessage": "chore(release): ${npm.name}@${version}",
    "requireCleanWorkingDir": false,
    "requireCommits": true,
    "requireCommitsFail": false,
    "commitsPath": "."
  },
  "npm": {
    "skipChecks": true
  }
}

When I run release-it I get an incorrectly calculated version bump - experimenting with git history shows that the new version is calculated by counting changes across the entire history of commits, and all the tags of previously released versions are being ignored.

From what I can tell there are two related problems occurring. The first is that when I try to set tagPrefix manually in the above json it is ignored, apparently because I have set git.tagName and getInitialOptions only refers to this setting in calculating tagPrefix, ignoring and overriding any value that comes from .release-it.json. This behaviour contradicts the docs which state that "Options are passed verbatim to conventional-recommended-bump and conventional-changelog-core."

Second, I suspect that ${npm.name} is not being interpolated anywhere when evaluating the tagPrefix that getInitialOptions is calculating per the above. I say this because 1) when I inspect options at runtime I see the uninterpolated value, and this is then passed into conventional-recommended-bump which from its docs I don't think has any concept of interpolating variables in this way; and 2) when I comment out lines 15-16 in getInitialOptions and then set tagPrefix in .release-it.json to the relevant hard coded value, dry runs show the version bumps are now calculated correctly.

Thanks for your help.

@webpro
Copy link
Contributor

webpro commented Feb 15, 2024

Options are passed verbatim

What I meant here was (only) the plugin options. The plugin options should be sent to the libs you mention. That might also shed light on the ${npm.name} issue, right?

Feel free to open a PR with a fix here or in release-it core, happy to look into it.

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

2 participants