diff --git a/lib/functions/buildFileList.sh b/lib/functions/buildFileList.sh index ed48de18..7e1c3bbd 100755 --- a/lib/functions/buildFileList.sh +++ b/lib/functions/buildFileList.sh @@ -68,34 +68,6 @@ function BuildFileList() { # Need to build a list of all files changed # This can be pulled from the GITHUB_EVENT_PATH payload - ################ - # print header # - ################ - debug "----------------------------------------------" - debug "Pulling in code history and branches..." - - ################################################################################# - # Switch codebase back to the default branch to get a list of all files changed # - ################################################################################# - SWITCH_CMD=$( - git -C "${GITHUB_WORKSPACE}" pull --quiet - git -C "${GITHUB_WORKSPACE}" checkout "${DEFAULT_BRANCH}" 2>&1 - ) - - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? - - ############################## - # Check the shell for errors # - ############################## - if [ ${ERROR_CODE} -ne 0 ]; then - # Error - info "Failed to switch to ${DEFAULT_BRANCH} branch to get files changed!" - fatal "[${SWITCH_CMD}]" - fi - if [ "${GITHUB_EVENT_NAME}" == "push" ]; then ################ # push event # @@ -122,9 +94,6 @@ function BuildFileList() { ################ # PR event # ################ - ################ - # print header # - ################ DIFF_CMD="git -C ${GITHUB_WORKSPACE} diff --name-only ${DEFAULT_BRANCH}...${GITHUB_SHA} --diff-filter=d" GenerateFileDiff "$DIFF_CMD" fi diff --git a/lib/linter.sh b/lib/linter.sh index ae28c5a2..019daff1 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -474,6 +474,15 @@ GetGitHubVars() { ###################### GITHUB_ORG=$(jq -r '.repository.owner.login' <"${GITHUB_EVENT_PATH}") + ######################## + # Fix SHA for PR event # + ######################## + # Github sha on PR events is not the latest commit. + # https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request + if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then + GITHUB_SHA=$(jq -r .pull_request.head.sha <"$GITHUB_EVENT_PATH") + fi + ############################ # Validate we have a value # ############################