axion-release-plugin
axion-release-plugin copied to clipboard
Sorting with useHighestVersion=true
Sorting needs to be changed when useHigestVersion is set to true. Currently alphabetical sorting is used, so having 1.0.1 and 1.0.10 versions will result in incorrect current version resolution
Can you create a test in VersionSorterTest class that would reproduce this behaviour? As far as I can tell Version object comparison is used, which understands semver.
Sorry my initial description is incorrect. It only happens when it comes to pre release version resolution. Here is a test that I made for it.
def "should resolve highest pre release version correctly"() {
when:
def versionData = sorter.pickTaggedCommit(
TaggedCommits.fromListOfCommits(new ScmPosition("a", "a", "master"),
[new TagsOnCommit('a', ['release-1.0.0-rc1', 'release-1.0.0-rc2', 'release-1.0.0-rc10'])]),
true,
false,
~/.*-rc$/,
factory
)
then:
versionData.version.toString() == '1.0.0-rc10'
}
It is true the Version comparison is used, but that poses a problem when the version includes also build meta data since the default Version comparison ignores that part.
In my project I have cases where feature branches increment the build meta data of the version. When I call release in the feature branch and then currentVersion I'm getting a SNAPSHOT version instead of the released one (the git tagging is working as intended though). The problem is the commit where the feature branch is branched off has the same Major.Minor.Patch.PreRelease version as the new feature commit (i.e. v1.1.0-rc1 and v1.1.0-rc1+1) and the oldest commit is being picked up.
I wonder if Version.compareWithBuildsTo() should always be used or whether another option should be used in combination with useHighestVersion