Skip to content

Commit

Permalink
Propogate git exceptions and fail the build
Browse files Browse the repository at this point in the history
  • Loading branch information
mattprecious committed Feb 4, 2016
1 parent 445707b commit 01fc770
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,25 @@ repositories {
mavenCentral()
}

def gitSha = 'git rev-parse --short HEAD'.execute([], project.rootDir).text.trim()
def gitTimestamp = 'git log -n 1 --format=%at'.execute([], rootDir).text.trim()
def gitSha() {
def p = 'git rev-parse --short HEAD'.execute([], project.rootDir)
p.waitFor()
if (p.exitValue() != 0) {
throw new RuntimeException(p.errorStream.text)
}

return p.text.trim()
}

def gitTimestamp() {
def p = 'git log -n 1 --format=%at'.execute([], rootDir)
p.waitFor()
if (p.exitValue() != 0) {
throw new RuntimeException(p.errorStream.text)
}

return p.text.trim()
}

def isCi = "true".equals(System.getenv("CI"))
def preDexEnabled = "true".equals(System.getProperty("pre-dex", "true"))
Expand Down Expand Up @@ -73,8 +90,8 @@ android {

signingConfig signingConfigs.u2020

buildConfigField 'String', 'GIT_SHA', "\"${gitSha}\""
buildConfigField 'long', 'GIT_TIMESTAMP', "${gitTimestamp}"
buildConfigField 'String', 'GIT_SHA', "\"${gitSha()}\""
buildConfigField 'long', 'GIT_TIMESTAMP', "${gitTimestamp()}L"

testInstrumentationRunner "com.jakewharton.u2020.U2020TestRunner"
}
Expand Down

0 comments on commit 01fc770

Please sign in to comment.