38 lines
836 B
D
38 lines
836 B
D
module verinfo;
|
|
|
|
import std.algorithm: startsWith;
|
|
import version_;
|
|
import std.array : split, join;
|
|
|
|
string getDasterVersion() {
|
|
auto verstr = dasterVersion;
|
|
if (verstr.startsWith("v"))
|
|
verstr = verstr[1 .. $];
|
|
auto parts = verstr.split("-");
|
|
if (parts.length >= 3) {
|
|
if (parts[$-1].length == 8 && parts[$-1][1 .. $].isHexNumber() && parts[$-2].isNumber())
|
|
verstr = parts[0 .. $-2].join("-") ~ "+" ~ parts[$-2 .. $].join("-");
|
|
}
|
|
return verstr;
|
|
}
|
|
|
|
private bool isHexNumber(string str) {
|
|
foreach (ch; str)
|
|
switch (ch) {
|
|
case '0': .. case '9': break;
|
|
case 'a': .. case 'f': break;
|
|
case 'A': .. case 'F': break;
|
|
default: return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private bool isNumber(string str) {
|
|
foreach (ch; str)
|
|
switch (ch) {
|
|
case '0': .. case '9': break;
|
|
default: return false;
|
|
}
|
|
return true;
|
|
}
|