From 878c5f39fc7be682c6fb137b345166ffe6d6b20f Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 16 Dec 2022 14:17:22 -0700 Subject: [PATCH 1/3] fix: fail when the merge base is not found --- diff-sha.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/diff-sha.sh b/diff-sha.sh index 1b0af7cfd6c..fc529d6835d 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -270,12 +270,12 @@ else # shellcheck disable=SC2086 git fetch $EXTRA_ARGS -u --progress --deepen="$i" origin $TARGET_BRANCH $CURRENT_SHA 1>/dev/null 2>&1 - - if ((i > max_depth)); then - echo "::error::Unable to locate a common ancestor between $TARGET_BRANCH and $CURRENT_BRANCH with: $PREVIOUS_SHA$DIFF$CURRENT_SHA" - exit 1 - fi done + + if ((i > max_depth)); then + echo "::error::Unable to locate a common ancestor between $TARGET_BRANCH and $CURRENT_BRANCH with: $PREVIOUS_SHA$DIFF$CURRENT_SHA" + exit 1 + fi else echo "::debug::Not a shallow clone, skipping merge-base check." fi From eab1f10bb419b6f1efb9bc6d6f94c1e62e3cf83a Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 16 Dec 2022 14:19:07 -0700 Subject: [PATCH 2/3] Update diff-sha.sh --- diff-sha.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/diff-sha.sh b/diff-sha.sh index fc529d6835d..a93bdd73ea1 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -258,6 +258,11 @@ else break fi + if git diff-tree --name-only --ignore-submodules=all "$PREVIOUS_SHA$DIFF$CURRENT_SHA" 1>/dev/null 2>&1; then + echo "Using git diff-tree instead" + break + fi + if [[ -z "$INPUT_BASE_SHA" ]]; then NEW_PREVIOUS_SHA=$(git merge-base --fork-point "$TARGET_BRANCH" "$CURRENT_SHA") && exit_status=$? || exit_status=$? From 3085a5f8841a77c947e1b082ab661bd1ad30fa89 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 16 Dec 2022 14:26:59 -0700 Subject: [PATCH 3/3] Update diff-sha.sh --- diff-sha.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/diff-sha.sh b/diff-sha.sh index a93bdd73ea1..fc529d6835d 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -258,11 +258,6 @@ else break fi - if git diff-tree --name-only --ignore-submodules=all "$PREVIOUS_SHA$DIFF$CURRENT_SHA" 1>/dev/null 2>&1; then - echo "Using git diff-tree instead" - break - fi - if [[ -z "$INPUT_BASE_SHA" ]]; then NEW_PREVIOUS_SHA=$(git merge-base --fork-point "$TARGET_BRANCH" "$CURRENT_SHA") && exit_status=$? || exit_status=$?