A mobile app for thmmy.gr
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

55 lines
1.1 KiB

import org.ajoberstar.grgit.Grgit
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.ajoberstar.grgit:grgit-core:5.0.0'
}
}
def getGrgit() {
return Grgit.open(currentDir: project.rootDir)
}
def getCurrentBranch() {
try {
def grgit = getGrgit()
def currentBranch = grgit.branch.getCurrent().name
grgit.close()
return currentBranch
} catch (Exception ignored) {
return ""
}
}
def getCommitHash() {
try {
def grgit = getGrgit()
def commitHash = grgit.head().id
grgit.close()
return commitHash
} catch (Exception ignored) {
return ""
}
}
//Will return true if there are no uncommitted changes
def isClean() {
try {
def grgit = getGrgit()
def isClean = grgit.status().isClean()
grgit.close()
return isClean
} catch (Exception ignored) {
return true
}
}
ext {
getCurrentBranch = this.&getCurrentBranch
getCommitHash = this.&getCommitHash
isClean = this.&isClean
}