git not required to build
This commit is contained in:
parent
8948645832
commit
e9cbd7a51e
72
build.gradle
72
build.gradle
@ -24,42 +24,48 @@ def buildNumber = ""
|
|||||||
def semver = ""
|
def semver = ""
|
||||||
def date = ""
|
def date = ""
|
||||||
ext {
|
ext {
|
||||||
git = org.ajoberstar.grgit.Grgit.open(file(".git"))
|
try {
|
||||||
date = git.head().date.format("yy.MM.dd")
|
git = org.ajoberstar.grgit.Grgit.open(file(".git"))
|
||||||
revision = "-${git.head().abbreviatedId}"
|
date = git.head().date.format("yy.MM.dd")
|
||||||
parents = git.head().parentIds;
|
revision = "-${git.head().abbreviatedId}"
|
||||||
index = -96; // Offset to match CI
|
parents = git.head().parentIds;
|
||||||
int major, minor, patch;
|
index = -96; // Offset to match CI
|
||||||
major = minor = patch = 0;
|
int major, minor, patch;
|
||||||
for (;parents != null && !parents.isEmpty();index++) {
|
major = minor = patch = 0;
|
||||||
int majorCount, minorCount, patchCount;
|
for (; parents != null && !parents.isEmpty(); index++) {
|
||||||
patchCount = minor == 0 && major == 0 ? 1 : 0;
|
int majorCount, minorCount, patchCount;
|
||||||
commit = git.getResolve().toCommit(parents.get(0));
|
patchCount = minor == 0 && major == 0 ? 1 : 0;
|
||||||
for (String line : commit.fullMessage.tokenize("\n")) {
|
commit = git.getResolve().toCommit(parents.get(0));
|
||||||
switch (line.replaceAll("- ", "").split(" ")[0].toLowerCase()) {
|
for (String line : commit.fullMessage.tokenize("\n")) {
|
||||||
case "minor":
|
switch (line.replaceAll("- ", "").split(" ")[0].toLowerCase()) {
|
||||||
case "added":
|
case "minor":
|
||||||
case "add":
|
case "added":
|
||||||
case "change":
|
case "add":
|
||||||
case "changed":
|
case "change":
|
||||||
case "changes":
|
case "changed":
|
||||||
if (major == 0) {minorCount = 1; patchCount = 0;}
|
case "changes":
|
||||||
break;
|
if (major == 0) {
|
||||||
case "refactor":
|
minorCount = 1; patchCount = 0;
|
||||||
case "remove":
|
}
|
||||||
case "major":
|
break;
|
||||||
patchCount = minorCount = 0;
|
case "refactor":
|
||||||
majorCount = 1;
|
case "remove":
|
||||||
break;
|
case "major":
|
||||||
|
patchCount = minorCount = 0;
|
||||||
|
majorCount = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
major += majorCount;
|
||||||
|
minor += minorCount;
|
||||||
|
patch += patchCount;
|
||||||
|
parents = commit.getParentIds()
|
||||||
}
|
}
|
||||||
major += majorCount;
|
buildNumber = "-${index}"
|
||||||
minor += minorCount;
|
semver = "-${major}.${minor}.${patch}"
|
||||||
patch += patchCount;
|
} catch (Throwable ignore) {
|
||||||
parents = commit.getParentIds()
|
revision = "unknown";
|
||||||
}
|
}
|
||||||
buildNumber = "-${index}"
|
|
||||||
semver = "-${major}.${minor}.${patch}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
version = date + revision + buildNumber + semver
|
version = date + revision + buildNumber + semver
|
||||||
|
Loading…
Reference in New Issue
Block a user