From a84c8f54f9312e43db81350c8282e6404934e0cd Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 10 Dec 2022 00:30:40 -0700 Subject: [PATCH] Update diff-sha.sh --- diff-sha.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/diff-sha.sh b/diff-sha.sh index 599ef9da..3bda566e 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -220,7 +220,7 @@ else depth=$INPUT_FETCH_DEPTH max_depth=$INPUT_MAX_FETCH_DEPTH - while ! git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA$DIFF$CURRENT_SHA" 1>/dev/null 2>&1; do + for ((i=0; i&1) && exit_status=$? || exit_status=$? - if [[ $depth -gt $max_depth ]]; then - echo "::error::Unable to locate a common ancestor between $TARGET_BRANCH and $CURRENT_SHA" - exit 1 + if git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA$DIFF$CURRENT_SHA" 1>/dev/null 2>&1; then + break fi - - depth=$((depth + 300)) done + + if ((i >= max_depth)); then + echo "::error::Unable to locate a common ancestor between $TARGET_BRANCH and $CURRENT_SHA" + exit 1 + fi else echo "::debug::Not a shallow clone, skipping merge-base check." fi