git-cliff icon indicating copy to clipboard operation
git-cliff copied to clipboard

Strip the version prefix when using `--tag-pattern` in monorepo context

Open EvanCarroll opened this issue 10 months ago • 4 comments

Is there an existing issue or pull request for this?

  • [x] I have searched the existing issues and pull requests

Feature description

Currently in a monorepo the tag could be something foo-1.0.0 and the version field in the context reports that without modification. This is not the version though, it's the project and version marshaled.

Desired solution

the version should be 1.0.0. the tag should be foo-1.0.0

Alternatives considered

If we can't break compat (but I would hope we could) then somewhere in the context 1.0.0 should be made available.

Additional context

No response

EvanCarroll avatar Mar 01 '25 01:03 EvanCarroll

I was able to work around this in the template doing,

{{ version | split(pat="-") | last }}

EvanCarroll avatar Mar 01 '25 02:03 EvanCarroll

Does that mean we need to derive the monorepo name from the current directory and remove it from the version? Is there another way?

Each project has a different versioning scheme and this seems overly specific tbh - I'd rather the user to configure it like you did in the template :)

orhun avatar Mar 01 '25 22:03 orhun

Sure, when providing --tag-pattern="foo-", take the latest tag and simply remove the version number it would otherwise bump with --bump. The rest of it is the "project name."

EvanCarroll avatar Mar 02 '25 00:03 EvanCarroll

Tag pattern is a regex though so I'm not sure a plain string-replace would work in all the cases. We could do a regex-replace instead but yeah, it won't be pretty 🫠

orhun avatar Mar 02 '25 09:03 orhun