Permalink
Browse files

fix Versionsgradle

  • Loading branch information...
StefanLindel committed Nov 22, 2017
1 parent f7961d9 commit 5578003ef38f4d283cafacabfb52161b8bba0404
Showing with 31 additions and 22 deletions.
  1. +31 −22 gradle/version.gradle
View
@@ -1,28 +1,14 @@
import java.text.SimpleDateFormat
ext{
try{
buildAntCompile.execute()
buildAnt.execute()
project.ext.Revisionnumber = Integer.parseInt(ant.Revisionnumber)
if (project.hasProperty("branch")) {
project.ext.Branchname = ant.Branchname + " " + project.get("branch")
}else {
project.ext.Branchname = ant.Branchname
}
project.ext.LastCommit = ant.LastCommit
project.ext.GitTag = Integer.parseInt(ant.GitTag)
}catch(Exception e) {
println e
project.ext.Revisionnumber = revisionNumber()
if (project.hasProperty("branch")) {
project.ext.Branchname = project.get("branch")
} else {
project.ext.Branchname = ""
}
project.ext.LastCommit = getGitLastCommit()
project.ext.GitTag = getGitTag()
project.ext.Revisionnumber = revisionNumber()
if (project.hasProperty("branch")) {
project.ext.Branchname = project.get("branch")
} else {
project.ext.Branchname = getWorkingBranch()
}
project.ext.LastCommit = getGitLastCommit()
project.ext.GitTag = getGitTag()
gitVersion = new GITVersion(major: ext.majorNumber,minor: ext.GitTag, revision: ext.Revisionnumber, hash: ext.LastCommit, buildTime: buildTime(), branch: ext.Branchname, latest: project.hasProperty('latest'))
}
version = gitVersion
@@ -63,7 +49,7 @@ public class GITVersion {
} else {
"$major.$minor.$revision"
}
}
}
boolean isMaster() {
return branch.contains("master")
}
@@ -143,3 +129,26 @@ def revisionNumber() {
}
count
}
def getWorkingBranch() {
// Triple double-quotes for the breaklines
def commit, branch="", value
executeCommand("git", "rev-parse", "HEAD").eachLine {
commit = it.trim()
println "Commit: "+commit
executeCommand("git", "branch", "-r", "--contains", commit).eachLine {
if(it.startsWith("* ")) {
value = it.substring(1).trim()
} else {
value = it.trim()
}
if(value.lastIndexOf("/")>0) {
value = value.substring(value.lastIndexOf("/")+1)
}
branch = branch + " "+value
}
}
branch = branch.trim()
println "Git-Branch: " + branch
branch
}

0 comments on commit 5578003

Please sign in to comment.