Skip to content

Commit ad70be1

Browse files
committed
v3.1.1-SNAPSHOT - Add pre-release checking
1 parent 213ff4c commit ad70be1

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
<groupId>dev.hypera</groupId>
2424
<artifactId>UpdateLib</artifactId>
25-
<version>3.1.0-SNAPSHOT</version>
25+
<version>3.1.1-SNAPSHOT</version>
2626
<packaging>jar</packaging>
2727

2828
<name>UpdateLib</name>

src/main/java/dev/hypera/updatelib/UpdateLib.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
public class UpdateLib {
2929

30-
private final static String VERSION = "3.1.0-SNAPSHOT"; // Current UpdateLib version.
30+
private final static String VERSION = "3.1.1-SNAPSHOT"; // Current UpdateLib version.
3131

3232
private final long resourceId;
3333
private final String currentVersion;

src/main/java/dev/hypera/updatelib/objects/VersionScheme.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020

2121
public enum VersionScheme {
2222

23-
BASIC("MAJOR.MINOR", "^(v?)(?<major>0|[1-9]\\d*)\\.(?<minor>0|[1-9]\\d*)(?:-(?<prerelease>(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?$"), SEMANTIC("MAJOR.MINOR.PATCH - https://semver.org/", "^(v?)(?<major>0|[1-9]\\d*)\\.(?<minor>0|[1-9]\\d*)\\.(?<patch>0|[1-9]\\d*)(?:-(?<prerelease>(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+(?<buildmetadata>[0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"), CALENDAR("YYYY-MM-DD - https://calver.org", "^(v?)(?<year>\\d{4})-(?<month>\\d{2})-(?<day>\\d{2})$");
23+
BASIC("MAJOR.MINOR", "^(v?)(?<major>0|[1-9]\\d*)\\.(?<minor>0|[1-9]\\d*)(?:-(?<prerelease>(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?$"),
24+
SEMANTIC("MAJOR.MINOR.PATCH - https://semver.org/", "^(v?)(?<major>0|[1-9]\\d*)\\.(?<minor>0|[1-9]\\d*)\\.(?<patch>0|[1-9]\\d*)(?:-(?<prerelease>(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+(?<buildmetadata>[0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"),
25+
CALENDAR("YYYY-MM-DD - https://calver.org", "^(v?)(?<year>\\d{4})-(?<month>\\d{2})-(?<day>\\d{2})$");
2426

2527
private final String description;
2628
private final Pattern pattern;

src/main/java/dev/hypera/updatelib/utils/VersionUtils.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ public static VersionChange compare(VersionScheme versionScheme, String newVersi
5454
Check.notNull("new version", newVersion);
5555
Check.notNull("current version", currentVersion);
5656

57-
if(newVersion.equals(currentVersion))
58-
return VersionChange.NONE;
57+
// if(newVersion.equals(currentVersion))
58+
// return VersionChange.NONE;
5959

6060
Matcher matcher = versionScheme.getPattern().matcher(newVersion);
6161
Matcher currentMatcher = versionScheme.getPattern().matcher(currentVersion);
@@ -111,9 +111,12 @@ public static VersionChange compare(VersionScheme versionScheme, String newVersi
111111
* @since 3.0.0-SNAPSHOT
112112
*/
113113
private static boolean safeCheck(String currentGroup, String newGroup) {
114-
if(null == currentGroup || currentGroup.equals("") || null == newGroup || newGroup.equals(""))
114+
if(isEmpty(currentGroup) && isEmpty(newGroup))
115115
return false;
116116

117+
if(isEmpty(currentGroup) || isEmpty(newGroup))
118+
return true;
119+
117120
int currentInt;
118121
int newInt;
119122

@@ -127,6 +130,12 @@ private static boolean safeCheck(String currentGroup, String newGroup) {
127130
return newInt > currentInt;
128131
}
129132

133+
private static boolean isEmpty(String one) {
134+
if(null == one) return true;
135+
if(one.equals("")) return true;
136+
return false;
137+
}
138+
130139
@Internal
131140
public enum VersionChange {
132141
NONE, MAJOR, MINOR, PATCH, PRE_RELEASE, METADATA, YEAR, MONTH, DAY

0 commit comments

Comments
 (0)