From ef8591de30d4dbf1ae8d2ec0c1c8d2f505c4aac3 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sun, 4 Dec 2022 23:33:22 -0700 Subject: [PATCH] Updated to use merge-base --- diff-sha.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/diff-sha.sh b/diff-sha.sh index 154df435..43346aa5 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -200,8 +200,12 @@ else 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=$? - + PREVIOUS_SHA=$(git merge-base "$TARGET_BRANCH" "$CURRENT_SHA" 2>&1) && exit_status=$? || exit_status=$? + + if [[ -z "$PREVIOUS_SHA" ]]; then + PREVIOUS_SHA=$GITHUB_EVENT_PULL_REQUEST_BASE_SHA && exit_status=$? || exit_status=$? + fi + 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