From f282e19e523425ed86464aef10c890e6e583172c Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sun, 4 Dec 2022 23:27:32 -0700 Subject: [PATCH] Updated to use merge-base --- diff-sha.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/diff-sha.sh b/diff-sha.sh index 9435ea1a..154df435 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -203,7 +203,7 @@ 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 merge-base origin/"$TARGET_BRANCH" HEAD 2>&1) && exit_status=$? || exit_status=$? + PREVIOUS_SHA=$(git rev-parse origin/"$TARGET_BRANCH" 2>&1) && exit_status=$? || exit_status=$? fi fi @@ -230,6 +230,8 @@ else # shellcheck disable=SC2086 git fetch $EXTRA_ARGS -u --progress --deepen="$depth" origin +"$GITHUB_REF":refs/remotes/origin/"$CURRENT_BRANCH" + PREVIOUS_SHA=$(git merge-base origin/"$TARGET_BRANCH" "$CURRENT_SHA" 2>&1) + if [[ $depth -gt $max_depth ]]; then echo "::error::Unable to locate a common ancestor between $TARGET_BRANCH and $CURRENT_SHA" exit 1