utility enhancements for template version release process

This commit is contained in:
Grahame Grieve 2020-02-17 22:29:09 +11:00
parent 44b23901a8
commit 6589d87ac0
2 changed files with 29 additions and 0 deletions

View File

@ -170,4 +170,28 @@ public class VersionUtilities {
return ok; return ok;
} }
public static String incMajorVersion(String v) {
assert isSemVer(v);
int[] parts = splitParts(v);
return Integer.toString(parts[0]+1)+".0.0";
}
public static String incMinorVersion(String v) {
assert isSemVer(v);
int[] parts = splitParts(v);
return Integer.toString(parts[0])+"."+Integer.toString(parts[1]+1)+".0";
}
public static String incPatchVersion(String v) {
assert isSemVer(v);
int[] parts = splitParts(v);
return Integer.toString(parts[0])+"."+Integer.toString(parts[1])+"."+Integer.toString(parts[2]+1);
}
private static int[] splitParts(String v) {
String[] p = v.split("\\.");
int[] i = new int[] {Integer.parseInt(p[0]),Integer.parseInt(p[1]),Integer.parseInt(p[2])};
return i;
}
} }

View File

@ -77,6 +77,11 @@ public class JSONUtil {
return e == null || e instanceof JsonNull ? null : e.getAsString(); return e == null || e instanceof JsonNull ? null : e.getAsString();
} }
public static boolean bool(JsonObject json, String name) {
JsonElement e = json.get(name);
return e == null || e instanceof JsonNull ? false : e.getAsBoolean();
}
public static String str(JsonObject json, String name1, String name2) { public static String str(JsonObject json, String name1, String name2) {
JsonElement e = json.get(name1); JsonElement e = json.get(name1);
if (e == null) if (e == null)