Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Semver does not follow Comparable contract for non standard versions #69

Open
anderruiz opened this issue Dec 1, 2022 · 1 comment
Open

Comments

@anderruiz
Copy link

new Semver("1.0.0.1").compareTo(new Semver("1.0.0.2"))==new Semver("1.0.0.2").compareTo(new Semver("1.0.0.1"))==-1

This happens because isGreaterThan() returns false (which is "ok") but isLowerThan() returns in both cases true because they isEquivalent()==false

@anderruiz
Copy link
Author

anderruiz commented Dec 2, 2022

Easiest fix:

    public int compareTo(Semver s2) {
        if(isGreaterThan(s2)) return 1;
        if(s2.isGreaterThan(this)) return -1;
        return 0;
    }

I can do a PR if you want

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant