From 9962dc418effb6f5aa6959cec01157744a3fda40 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Tue, 8 Nov 2022 09:00:45 -0700 Subject: [PATCH] fix: bug with invalid branch name --- diff-sha.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/diff-sha.sh b/diff-sha.sh index 443d3b59..3029cdda 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -45,8 +45,6 @@ fi if [[ -z $GITHUB_BASE_REF ]]; then echo "Running on a push event..." - TARGET_BRANCH=${GITHUB_REF/refs\/heads\//} && exit_status=$? || exit_status=$? - CURRENT_BRANCH=$TARGET_BRANCH && exit_status=$? || exit_status=$? echo "::debug::Getting HEAD SHA..." if [[ -n "$INPUT_UNTIL" ]]; then @@ -67,6 +65,9 @@ if [[ -z $GITHUB_BASE_REF ]]; then fi fi + TARGET_BRANCH=$(git name-rev --name-only "$CURRENT_SHA" 2>&1) && exit_status=$? || exit_status=$? + CURRENT_BRANCH=$TARGET_BRANCH && exit_status=$? || exit_status=$? + echo "::debug::Verifying the current commit SHA: $CURRENT_SHA" git rev-parse --quiet --verify "$CURRENT_SHA^{commit}" 1>/dev/null 2>&1 && exit_status=$? || exit_status=$? @@ -127,8 +128,6 @@ if [[ -z $GITHUB_BASE_REF ]]; then # shellcheck disable=SC2086 git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" PREVIOUS_SHA=$INPUT_BASE_SHA - TARGET_BRANCH=$(git name-rev --name-only "$PREVIOUS_SHA" 2>&1) && exit_status=$? || exit_status=$? - CURRENT_BRANCH=$TARGET_BRANCH fi echo "::debug::Target branch $TARGET_BRANCH..."