From 765ed1513e871f2784fc38c67be269d7cbcfb7e4 Mon Sep 17 00:00:00 2001 From: Stephen Mulrennan Date: Tue, 10 Sep 2024 10:01:16 +0100 Subject: [PATCH] SCAN-5687 : Add error handling around ref retrieval. --- src/config.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/config.js b/src/config.js index 119a930..e9d58ff 100644 --- a/src/config.js +++ b/src/config.js @@ -27,11 +27,18 @@ const getRef = () => { const thisBranchName = () => { - const ref = getRef(); + try { + const ref = getRef(); - const refParts = ref.split('/'); + const refParts = ref.split('/'); - return refParts[refParts.length-1]; + return refParts[refParts.length-1]; + } + catch (error) { + core.error(`Unable to get current branch name : ${error.message}`); + } + + return DEFAULT_BRANCH_NAME; }; const isDefaultBranch = () => {