From 7b68fcd08242de76b024a1810a1586f1922830d9 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Thu, 17 Nov 2022 12:59:15 -0700 Subject: [PATCH] Update diff-sha.sh --- diff-sha.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/diff-sha.sh b/diff-sha.sh index 167fe8a4..2c583f28 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -194,10 +194,14 @@ else if ! git rev-parse --quiet --verify "$PREVIOUS_SHA^{commit}" 1>/dev/null 2>&1; then # shellcheck disable=SC2046 - PREVIOUS_SHA=$(git rev-parse $(git branch -r --sort=-committerdate | head -1) 2>&1) && exit_status=$? || exit_status=$? + PREVIOUS_SHA=$(git rev-parse origin/"$CURRENT_BRANCH" 2>&1) && exit_status=$? || exit_status=$? fi else PREVIOUS_SHA=$GITHUB_EVENT_PULL_REQUEST_BASE_SHA && exit_status=$? || exit_status=$? + + if ! git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA"..."$CURRENT_SHA" 1>/dev/null 2>&1; then + PREVIOUS_SHA=$(git rev-parse origin/"$TARGET_BRANCH" 2>&1) && exit_status=$? || exit_status=$? + fi fi if [[ -z "$PREVIOUS_SHA" || "$PREVIOUS_SHA" == "$CURRENT_SHA" ]]; then