From 69d9410ad3fa8cea8b8aa5306e01ff37b65fcc9e Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 24 Sep 2022 19:59:18 -0600 Subject: [PATCH 1/2] chore: improve debug message. --- diff-sha.sh | 3 +++ get-base-sha.sh | 1 + 2 files changed, 4 insertions(+) diff --git a/diff-sha.sh b/diff-sha.sh index 434f2899c6b..13ff18fe6b7 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -57,6 +57,7 @@ else 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=$? @@ -64,6 +65,7 @@ if [[ -z $GITHUB_BASE_REF ]]; then PREVIOUS_SHA=$GITHUB_EVENT_BEFORE if [[ -z "$PREVIOUS_SHA" || "$PREVIOUS_SHA" == "0000000000000000000000000000000000000000" ]]; then + echo "::debug::First commit detected" PREVIOUS_SHA=$(git rev-parse "$(git branch -r --sort=-committerdate | head -1)") fi @@ -89,6 +91,7 @@ if [[ -z $GITHUB_BASE_REF ]]; then exit 1 fi else + echo "Running on a pull request event..." TARGET_BRANCH=$GITHUB_BASE_REF CURRENT_BRANCH=$GITHUB_HEAD_REF diff --git a/get-base-sha.sh b/get-base-sha.sh index c2fcee3c283..93bae610642 100644 --- a/get-base-sha.sh +++ b/get-base-sha.sh @@ -25,6 +25,7 @@ elif [[ "$INPUT_SINCE_LAST_REMOTE_COMMIT" == "true" ]]; then LAST_REMOTE_COMMIT="$GITHUB_EVENT_BEFORE" if [[ -z "$LAST_REMOTE_COMMIT" || "$LAST_REMOTE_COMMIT" == "0000000000000000000000000000000000000000" ]]; then + echo "::debug::First commit detected" LAST_REMOTE_COMMIT=$(git rev-parse "$(git branch -r --sort=-committerdate | head -1)") fi if [[ "$INPUT_SHA" == "$LAST_REMOTE_COMMIT" ]]; then From 4cd2d9f19ec4b76a1511b67dbb817a606d98f91a Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 24 Sep 2022 20:21:08 -0600 Subject: [PATCH 2/2] Fixed test --- diff-sha.sh | 2 +- get-base-sha.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/diff-sha.sh b/diff-sha.sh index 13ff18fe6b7..812c105bfa1 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -66,7 +66,7 @@ if [[ -z $GITHUB_BASE_REF ]]; then if [[ -z "$PREVIOUS_SHA" || "$PREVIOUS_SHA" == "0000000000000000000000000000000000000000" ]]; then echo "::debug::First commit detected" - PREVIOUS_SHA=$(git rev-parse "$(git branch -r --sort=-committerdate | head -1)") + PREVIOUS_SHA=$(git rev-parse "$(git branch -r --sort=-committerdate | head -1 | xargs)") fi if [[ "$PREVIOUS_SHA" == "$CURRENT_SHA" ]]; then diff --git a/get-base-sha.sh b/get-base-sha.sh index 93bae610642..3b6efb024c3 100644 --- a/get-base-sha.sh +++ b/get-base-sha.sh @@ -26,7 +26,7 @@ elif [[ "$INPUT_SINCE_LAST_REMOTE_COMMIT" == "true" ]]; then if [[ -z "$LAST_REMOTE_COMMIT" || "$LAST_REMOTE_COMMIT" == "0000000000000000000000000000000000000000" ]]; then echo "::debug::First commit detected" - LAST_REMOTE_COMMIT=$(git rev-parse "$(git branch -r --sort=-committerdate | head -1)") + LAST_REMOTE_COMMIT=$(git rev-parse "$(git branch -r --sort=-committerdate | head -1 | xargs)") fi if [[ "$INPUT_SHA" == "$LAST_REMOTE_COMMIT" ]]; then LAST_REMOTE_COMMIT=$(git rev-parse "$INPUT_SHA^1")