From 2e4e6363923a537f9acbc4ec0ba5fd9caa9bfa46 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 11 Nov 2022 07:39:00 -0700 Subject: [PATCH] Updated the retrieving the merge-base --- diff-sha.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/diff-sha.sh b/diff-sha.sh index 3a8680f9..85137c35 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -185,18 +185,17 @@ else if [[ "$INPUT_SINCE_LAST_REMOTE_COMMIT" == "false" ]]; then if [[ -f .git/shallow ]]; then depth=$INPUT_FETCH_DEPTH + max_depth=$INPUT_MAX_FETCH_DEPTH + + while [ -z "$( git merge-base --fork-point "$TARGET_BRANCH" HEAD )" ] || [ -z "$(git merge-base "$TARGET_BRANCH" HEAD)" ]; do + depth=$((depth + 300)) - while [ -z "$( git merge-base "$TARGET_BRANCH" HEAD )" ]; do # shellcheck disable=SC2086 git fetch $EXTRA_ARGS --deepen="$depth" origin "$TARGET_BRANCH" HEAD; - depth=$((depth * 10)) - max_depth=$INPUT_MAX_FETCH_DEPTH if [[ $depth -gt $max_depth ]]; then - if [ -z "$(git merge-base --fork-point "$TARGET_BRANCH" HEAD)" ]; then - echo "::error::Unable to locate a common ancestor between $TARGET_BRANCH and HEAD" - exit 1 - fi + echo "::error::Unable to locate a common ancestor between $TARGET_BRANCH and HEAD" + exit 1 fi done else