From 9d43c2bf0392bea330ecc6b86763198cce40fb51 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Thu, 6 Apr 2023 19:32:37 -0600 Subject: [PATCH 1/2] fix: investigate error finding merge base --- diff-sha.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/diff-sha.sh b/diff-sha.sh index c3651fa1783..3b2c12c2f09 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -263,6 +263,11 @@ else echo "::debug::Merge base is not in the local history, fetching remote target branch again..." echo "::debug::Attempt $i/10" done + + if [[ $i -eq 10 ]]; then + echo "::error::Unable to find the merge base between $PREVIOUS_SHA and $CURRENT_SHA" + exit 1 + fi fi fi fi From 9a1e35a5da1ed499fdd6d1f89e519627b7d7de92 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Thu, 6 Apr 2023 20:04:17 -0600 Subject: [PATCH 2/2] Update diff-sha.sh --- diff-sha.sh | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/diff-sha.sh b/diff-sha.sh index 3b2c12c2f09..cd707b6bf96 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -251,23 +251,18 @@ else if [[ "$IS_SHALLOW" == "true" ]]; then # check if the merge base is in the local history - if ! git merge-base "$PREVIOUS_SHA" "$CURRENT_SHA" 1>/dev/null 2>&1; then + if ! git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA$DIFF$CURRENT_SHA" 1>/dev/null 2>&1; then echo "::debug::Merge base is not in the local history, fetching remote target branch..." # Fetch more of the target branch history until the merge base is found for i in {1..10}; do # shellcheck disable=SC2086 git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" origin +refs/heads/"$TARGET_BRANCH":refs/remotes/origin/"$TARGET_BRANCH" 1>/dev/null - if git merge-base "$PREVIOUS_SHA" "$CURRENT_SHA" 1>/dev/null 2>&1; then + if git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA$DIFF$CURRENT_SHA" 1>/dev/null 2>&1; then break fi echo "::debug::Merge base is not in the local history, fetching remote target branch again..." echo "::debug::Attempt $i/10" done - - if [[ $i -eq 10 ]]; then - echo "::error::Unable to find the merge base between $PREVIOUS_SHA and $CURRENT_SHA" - exit 1 - fi fi fi fi