From 7b2f7191f5dacf1cf5deeb278f6d8cee135e02a8 Mon Sep 17 00:00:00 2001 From: Sai Krishna Date: Thu, 3 Jan 2019 20:18:42 +0530 Subject: [PATCH] =?UTF-8?q?Fix=20for=20issue=20#1157=20Added=20try-catch?= =?UTF-8?q?=20block=20in=20getBuildVersion=20function=20in=20gitutils.grad?= =?UTF-8?q?le=20=E2=80=A6=20(#1158)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added try-catch block in getBuildVersion function in gitutils.gradle file. * Formatting fix * Add comment --- gitutils.gradle | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/gitutils.gradle b/gitutils.gradle index e84cb1eda..ffcc8e520 100644 --- a/gitutils.gradle +++ b/gitutils.gradle @@ -1,10 +1,15 @@ ext.getBuildVersion = { -> - def stdout = new ByteArrayOutputStream() - exec { - commandLine 'git', 'rev-parse', '--short', 'HEAD' - standardOutput = stdout + // Short-term fix for #1157. Should ideally look into why method is failing. + try { + def stdout = new ByteArrayOutputStream() + exec { + commandLine 'git' , 'rev-parse' , '--short' , 'HEAD' + standardOutput = stdout + } + return stdout.toString().trim() + } catch (ignored) { + return null } - return stdout.toString().trim() } ext.getBranchName = { ->