Skip to content

Commit

Permalink
Merge pull request #29 from mbeddr/check-git-available
Browse files Browse the repository at this point in the history
git versioning: add method to check if git is available
  • Loading branch information
coolya authored Nov 5, 2018
2 parents 0d45b14 + 7012a76 commit 03fbeda
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main/groovy/de/itemis/mps/gradle/GitBasedVersioning.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ import org.apache.tools.ant.taskdefs.condition.Os
import org.gradle.api.GradleException

class GitBasedVersioning {


/**
* Checks whenever git based versioning is available.
* */
static boolean isGitVersioningAvailable() {
try {
String output = getCommandOutput("git --version")
return output.startsWith("git version 2")
} catch (ignored) {
return false
}
}

static String getGitShortCommitHash() {
return getCommandOutput('git rev-parse --short HEAD').substring(0,7)
}
Expand Down

0 comments on commit 03fbeda

Please sign in to comment.