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

Is this correct behaviour when comparing versions #15

Open
aslak-dirdal opened this issue Aug 8, 2017 · 8 comments
Open

Is this correct behaviour when comparing versions #15

aslak-dirdal opened this issue Aug 8, 2017 · 8 comments

Comments

@aslak-dirdal
Copy link

aslak-dirdal commented Aug 8, 2017

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

@gihad
Copy link

gihad commented Sep 29, 2017

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"

@sschuberth
Copy link
Contributor

I believe this should have been fixed by my PR #20. Mind giving it a try?

@nomaed
Copy link

nomaed commented Oct 2, 2018

I still get

new Semver("2", SemverType.LOOSE).isEqualTo("2.0") // false

@sschuberth
Copy link
Contributor

sschuberth commented Oct 2, 2018

I actually had to do a fixup in PR #25, which is not in a released version yet. That should fix it.

Edit: No, it doesn't. Hmpf.

@nomaed
Copy link

nomaed commented Oct 2, 2018

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 ;)

@collinpeters
Copy link

I assume this is another variant of this:
new Semver("123", SemverType.NPM).satisfies("123") == false

@mvdobrinin
Copy link

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));

@piotrooo
Copy link

@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

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

7 participants