semver4j icon indicating copy to clipboard operation
semver4j copied to clipboard

isEqualTo has broken semantics for NPM type (is not symmetric)

Open broglep-work opened this issue 4 years ago • 2 comments

The changes in #36 resulted in quite unexpected isEqualTo semantics:

final Semver v1 = new Semver("2.10.1", Semver.SemverType.NPM);
final Semver v2 = new Semver("2.99", Semver.SemverType.NPM);

System.out.println(v1.isEqualTo(v2)); // --> true
System.out.println(v2.isEqualTo(v1)); // --> false

This violates basic symmetric requirement on the equality operation.

broglep-work avatar Jan 23 '20 11:01 broglep-work

I second that. Issue seems to be here: https://github.com/vdurmont/semver4j/blob/master/src/main/java/com/vdurmont/semver4j/Semver.java#L360

If version being checked against does not have patch (fx. 1.0 instead of 1.0.0) then the result is always true.

michaelkrog avatar May 24 '20 20:05 michaelkrog

@broglep-work if you are still interesting, I've made copy of this lib and fix bug reported by you. Look for version 2.0.1

piotrooo avatar Jul 22 '22 22:07 piotrooo