From 0eff79ca1a440ae9e92415312d3fa72880d03d21 Mon Sep 17 00:00:00 2001 From: Eugene Cheung Date: Sat, 16 Dec 2017 10:52:30 -0500 Subject: [PATCH] Prevent build from crashing when no Git or on Windows --- app/build.gradle | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 4aa1579e..67f81e0d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -20,11 +20,20 @@ repositories { } static def gitBranch() { - def branch = '' - def proc = 'git rev-parse --abbrev-ref HEAD'.execute() - proc.in.eachLine { line -> branch = line } - proc.err.eachLine { line -> println line } - proc.waitFor() + def branch = 'GitHub' + try { + def gitcheck = 'command -v git >/dev/null 2>&1'.execute() + gitcheck.waitFor() + if (gitcheck.exitValue() == 0) { + def proc = 'git rev-parse --abbrev-ref HEAD'.execute() + proc.in.eachLine { line -> branch = line } + proc.err.eachLine { line -> println line } + proc.waitFor() + } + } catch (Exception e) { + // Do nothing + println e + } branch }