axion-release-plugin icon indicating copy to clipboard operation
axion-release-plugin copied to clipboard

Sorting with useHighestVersion=true

Open v-akimov opened this issue 5 years ago • 3 comments
trafficstars

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

v-akimov avatar May 25 '20 09:05 v-akimov

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.

adamdubiel avatar May 30 '20 17:05 adamdubiel

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'
}

v-akimov avatar May 31 '20 07:05 v-akimov

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

ssi-aguilar-ja avatar Mar 24 '22 20:03 ssi-aguilar-ja