From 88645c097703ca811eddd47b18e14789042eaaa9 Mon Sep 17 00:00:00 2001 From: Gabriel Diaz Date: Tue, 12 Jan 2021 13:55:02 -0500 Subject: [PATCH] Move switch back to code branch (#1139) Co-authored-by: Lukas Gravley --- lib/functions/buildFileList.sh | 44 +++++++++++++++++----------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/lib/functions/buildFileList.sh b/lib/functions/buildFileList.sh index 008a9e23..2660b228 100755 --- a/lib/functions/buildFileList.sh +++ b/lib/functions/buildFileList.sh @@ -161,6 +161,27 @@ function BuildFileList() { warn "No files were found in the GITHUB_WORKSPACE:[${GITHUB_WORKSPACE}] to lint!" fi + if [ "${VALIDATE_ALL_CODEBASE}" == "false" ]; then + ######################################### + # Need to switch back to branch of code # + ######################################### + SWITCH2_CMD=$(git -C "${GITHUB_WORKSPACE}" checkout --progress --force "${GITHUB_SHA}" 2>&1) + + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? + + ############################## + # Check the shell for errors # + ############################## + if [ ${ERROR_CODE} -ne 0 ]; then + # Error + error "Failed to switch back to branch!" + fatal "[${SWITCH2_CMD}]" + fi + fi + ################################################ # Iterate through the array of all files found # ################################################ @@ -183,7 +204,7 @@ function BuildFileList() { ########################################################## if [ ! -f "${FILE}" ]; then # File not found in workspace - debug "File:{$FILE} existed in commit data, but not found on file system, skipping..." + warn "File:{$FILE} existed in commit data, but not found on file system, skipping..." continue fi @@ -669,27 +690,6 @@ function BuildFileList() { debug "" done - if [ "${VALIDATE_ALL_CODEBASE}" == "false" ]; then - ######################################### - # Need to switch back to branch of code # - ######################################### - SWITCH2_CMD=$(git -C "${GITHUB_WORKSPACE}" checkout --progress --force "${GITHUB_SHA}" 2>&1) - - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? - - ############################## - # Check the shell for errors # - ############################## - if [ ${ERROR_CODE} -ne 0 ]; then - # Error - error "Failed to switch back to branch!" - fatal "[${SWITCH2_CMD}]" - fi - fi - ################ # Footer print # ################