-
Notifications
You must be signed in to change notification settings - Fork 22
feat!: make version comparison semver compliant #115
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
Changes from all commits
fbf9c30
9acfbf1
746a9d9
f4b5ab7
5d01e21
f41d2f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ | |
package org.terasology.gestalt.module.dependencyresolution; | ||
|
||
import org.terasology.gestalt.naming.Name; | ||
import org.terasology.gestalt.naming.SemverExpression; | ||
import org.terasology.gestalt.naming.Version; | ||
import org.terasology.gestalt.naming.VersionRange; | ||
|
||
|
@@ -73,9 +72,9 @@ public void setMinVersion(Version value) { | |
public Version getMaxVersion() { | ||
if (maxVersion == null) { | ||
if (minVersion.getMajor() == 0) { | ||
return minVersion.getNextMinorVersion(); | ||
return minVersion.getCoreVersion().getNextMinorVersion(); | ||
} | ||
return minVersion.getNextMajorVersion(); | ||
return minVersion.getCoreVersion().getNextMajorVersion(); | ||
} | ||
return maxVersion; | ||
} | ||
|
@@ -109,25 +108,10 @@ public void setOptional(boolean optional) { | |
} | ||
|
||
/** | ||
* @return The range of supported versions | ||
* Returns a predicate that yields true when applied to version that is within the version range described by this dependency information | ||
*/ | ||
public VersionRange versionRange() { | ||
return new VersionRange(getMinVersion(), getMaxVersion()); | ||
} | ||
|
||
public Predicate<Version> versionPredicate() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thinking about types here.
which makes me think we want to keep the return type as VersionRange after all. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let me bring up my question about sum types again... 🙄 nargh There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this one needs sum types. One class can implement both |
||
if (maxVersion != null) { | ||
return versionRange(); | ||
} else { | ||
String source; | ||
if (minVersion.isSnapshot()) { | ||
// semver doesn't like snapshots in caret ranges? | ||
source = minVersion + " | ^" + minVersion.getNextPatchVersion(); | ||
} else { | ||
source = "^" + minVersion; | ||
} | ||
return new SemverExpression(source); | ||
} | ||
return new VersionRange(getMinVersion(), getMaxVersion()); | ||
} | ||
|
||
@Override | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,7 @@ public Version getUpperBound() { | |
* @return Whether version falls within the range | ||
*/ | ||
public boolean contains(Version version) { | ||
return version.compareTo(lowerBound.getSnapshot()) >= 0 && version.compareTo(upperBound.getSnapshot()) < 0; | ||
return version.compareTo(lowerBound) >= 0 && version.compareTo(upperBound.getSnapshot()) < 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This works for Terasology's current use cases. I agree that having one VersionRange class is better than having the one-foot-in-one-foot-out thing I had going on. The edge cases this falls apart on are things like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That sounds like completely removing Technically, SemVer does not describe anything special about |
||
} | ||
|
||
@Override | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@keturn this is actually used in the Terasology modules builds 🙈 Guess we need to bring this method back to make that work again.