mirror of
https://github.com/Anuken/Mindustry.git
synced 2024-12-22 17:03:59 +07:00
add gradle build option to show commit hash (#10264)
This commit is contained in:
parent
a7c3ce5d8c
commit
ea5975737c
@ -89,6 +89,10 @@ allprojects{
|
||||
return project.getProperties()["buildversion"]
|
||||
}
|
||||
|
||||
getCommitHash = {
|
||||
return 'git rev-parse --verify --short HEAD'.execute().text.trim()
|
||||
}
|
||||
|
||||
getPackage = {
|
||||
return project.ext.mainClassName.substring(0, project.ext.mainClassName.indexOf("desktop") - 1)
|
||||
}
|
||||
@ -133,6 +137,10 @@ allprojects{
|
||||
props["number"] = versionNumber
|
||||
props["modifier"] = versionModifier
|
||||
props["build"] = buildid
|
||||
props["commitHash"] = "unknown"
|
||||
if(project.hasProperty("showCommitHash")){
|
||||
props["commitHash"] = getCommitHash()
|
||||
}
|
||||
|
||||
props.store(pfile.newWriter(), "Autogenerated file. Do not modify.")
|
||||
}
|
||||
|
@ -12,6 +12,8 @@ public class Version{
|
||||
public static String type = "unknown";
|
||||
/** Build modifier, e.g. 'alpha' or 'release' */
|
||||
public static String modifier = "unknown";
|
||||
/** Git commit hash (short) */
|
||||
public static String commitHash = "unknown";
|
||||
/** Number specifying the major version, e.g. '4' */
|
||||
public static int number;
|
||||
/** Build number, e.g. '43'. set to '-1' for custom builds. */
|
||||
@ -32,6 +34,7 @@ public class Version{
|
||||
type = map.get("type");
|
||||
number = Integer.parseInt(map.get("number", "4"));
|
||||
modifier = map.get("modifier");
|
||||
commitHash = map.get("commitHash");
|
||||
if(map.get("build").contains(".")){
|
||||
String[] split = map.get("build").split("\\.");
|
||||
try{
|
||||
@ -73,6 +76,6 @@ public class Version{
|
||||
if(build == -1){
|
||||
return "custom build";
|
||||
}
|
||||
return (type.equals("official") ? modifier : type) + " build " + build + (revision == 0 ? "" : "." + revision);
|
||||
return (type.equals("official") ? modifier : type) + " build " + build + (revision == 0 ? "" : "." + revision) + (commitHash.equals("unknown") ? "" : " (" + commitHash + ")");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user