From 4203489288873ed8a126dc274b0bf9e4a155e4a4 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Tue, 15 Nov 2022 11:08:51 -0700 Subject: [PATCH] Update diff-sha.sh --- diff-sha.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/diff-sha.sh b/diff-sha.sh index 434bab4c..fb60c281 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -211,16 +211,18 @@ else depth=$INPUT_FETCH_DEPTH max_depth=$INPUT_MAX_FETCH_DEPTH - while [ -z "$( git merge-base --fork-point "$TARGET_BRANCH" "$CURRENT_SHA" )" ] || [ -z "$(git merge-base "$TARGET_BRANCH" "$CURRENT_SHA")" ] || [ -z "$(git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA"..."$CURRENT_SHA" | head -1)" ]; do - depth=$((depth + 300)) + while ! git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA"..."$CURRENT_SHA" 1>/dev/null; do + echo "Fetching $depth commits..." # shellcheck disable=SC2086 - git fetch $EXTRA_ARGS --deepen="$depth" origin "$TARGET_BRANCH" HEAD; + git fetch $EXTRA_ARGS --deepen="$depth" origin "$TARGET_BRANCH" "$CURRENT_SHA"; if [[ $depth -gt $max_depth ]]; then - echo "::error::Unable to locate a common ancestor between $TARGET_BRANCH and HEAD" + echo "::error::Unable to locate a common ancestor between $TARGET_BRANCH and "$CURRENT_SHA"" exit 1 fi + + depth=$((depth + 300)) done else echo "::debug::Not a shallow clone, skipping merge-base check."