restechnica / semverbot

A CLI which automates semver versioning.
Mozilla Public License 2.0
136 stars 7 forks source link

Inconsistent version prediction #76

Open emulanob opened 3 weeks ago

emulanob commented 3 weeks ago

Hey there!

I spent quite a few hours today testing the git-commit mode. My goal was to determine the easisest way for my team to have "regular" minor version releases and keep the ability to bump the major version when needed by prefixing the commit message.

I ended up noticing inconsistent version predictions.

For example, given the following semver config:

mode = "git-commit"

[git]

[git.config]
email = "semverbot@github.com"
name = "semverbot"

[git.tags]
prefix = "v"

[semver]
patch = ["hotfix", "bugfix", "fix", "bug"]
minor = ["feature", "feat", "release"]
major = ["breaking", "major"]

[modes]

[modes.git-branch]
delimiters = "/"

[modes.git-commit]
delimiters = "[]/"

and the following commit message:

git commit -m "[breaking] [feature] [hotfix]" --amend

I got 3 different predictions in 3 tries.

image

So maybe when this gets fixed there could also be a way to enforce hierarchy in the matching? Which in my opinion should always go major --> minor --> patch.

Thanks!

shiouen commented 2 weeks ago

Hey! Thanks for the post, I'll have a look at it tomorrow. Seems like a pretty fundamental issue.

Could you elaborate more on the hierarchy you mentioned?

emulanob commented 2 weeks ago

Thanks for looking into this!

With hierarchy I meant that, if you have more than 1 positive match, the higher one should be bumped. e.g.:

git commit -m "[breaking] [feature] [hotfix]" --amend

Since all 3 parts of the semver have a positive match in this string, the one to be bumped should be the Major.