semver4j
semver4j copied to clipboard
Is this correct behaviour when comparing versions
Using
compile 'com.vdurmont:semver4j:2.0.3'
Semver A = new Semver("2.0", Semver.SemverType.LOOSE);
Semver B = new Semver("2.0.0", Semver.SemverType.LOOSE);
A.isGreaterThan(B); // -> false
B.isGreaterThan(A); // -> false
B.isEquivalentTo(A); // -> false
A.isEquivalentTo(B); // -> false
B.isLowerThan(A); // -> true
A.isLowerThan(B); // -> true
Yes, I'm hitting the same issue. The library doesn't know how to compare correctly when comparing versions that don't have the same version type. e.g.: "MAJOR" vs "MAJOR.MINOR.PATCH"
I believe this should have been fixed by my PR https://github.com/vdurmont/semver4j/pull/20. Mind giving it a try?
I still get
new Semver("2", SemverType.LOOSE).isEqualTo("2.0") // false
I actually had to do a fixup in PR https://github.com/vdurmont/semver4j/pull/25, which is not in a released version yet. That should fix it.
Edit: No, it doesn't. Hmpf.
I worked around it by adding a helper function that converts everything .toStrict()
, so
private Semver version(String versionString) {
return new Semver(versionString, SemverType.LOOSE).toStrict();
}
//////
version("2").isEqualTo(version("2.0")) // true
But I don't like this workaround ;)
I assume this is another variant of this:
new Semver("123", SemverType.NPM).satisfies("123") == false
This is still an issue.
// should be true BUT IS FALSE
new Semver("2.0", Semver.SemverType.LOOSE).isGreaterThanOrEqualTo("2.0.0");
// should be true BUT IS FALSE
new Semver("2.0", Semver.SemverType.LOOSE).isEqualTo("2.0.0");
// should be true BUT IS FALSE
new Semver("2.0.0", Semver.SemverType.STRICT).isGreaterThanOrEqualTo(new Semver("2.0", Semver.SemverType.LOOSE));
@aslak-dirdal if you are still interesting, I've made copy of this lib and fix bug reported by you. Look for version 2.0.1