From 65dc0e47e94e3b4489dfbbfc04b98bd78e8f80f7 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Mon, 12 Dec 2022 00:18:33 -0700 Subject: [PATCH 1/4] chore: update error handling --- diff-sha.sh | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/diff-sha.sh b/diff-sha.sh index dc6c3a6c..b145fec0 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -205,10 +205,6 @@ else fi else PREVIOUS_SHA=$GITHUB_EVENT_PULL_REQUEST_BASE_SHA - - if ! git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA$DIFF$CURRENT_SHA" 1>/dev/null 2>&1; then - PREVIOUS_SHA=$(git merge-base "$PREVIOUS_SHA" "$CURRENT_SHA" 2>&1) && exit_status=$? || exit_status=$? - fi fi if [[ -z "$PREVIOUS_SHA" || "$PREVIOUS_SHA" == "$CURRENT_SHA" ]]; then @@ -224,16 +220,15 @@ else echo "Fetching $depth commits..." # shellcheck disable=SC2086 - git fetch $EXTRA_ARGS -u --progress --deepen="$depth" origin +"$GITHUB_REF":refs/remotes/origin/"$CURRENT_BRANCH" + git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" origin "$CURRENT_BRANCH" if git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA$DIFF$CURRENT_SHA" 1>/dev/null 2>&1; then - PREVIOUS_SHA=$(git merge-base "$TARGET_BRANCH" "$CURRENT_SHA" 2>&1) && exit_status=$? || exit_status=$? break fi done if ((i >= max_depth)); then - echo "::error::Unable to locate a common ancestor between $TARGET_BRANCH and $CURRENT_SHA" + echo "::error::Unable to locate a common ancestor between $TARGET_BRANCH and $CURRENT_BRANCH with: $PREVIOUS_SHA$DIFF$CURRENT_SHA" exit 1 fi else From 17ae17127cf91edd6e904ea3118a947a49079452 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Mon, 12 Dec 2022 00:19:02 -0700 Subject: [PATCH 2/4] Update diff-sha.sh --- diff-sha.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diff-sha.sh b/diff-sha.sh index b145fec0..f4ca3cb5 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -220,7 +220,7 @@ else echo "Fetching $depth commits..." # shellcheck disable=SC2086 - git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" origin "$CURRENT_BRANCH" + git fetch $EXTRA_ARGS -u --progress --deepen="$depth" origin "$CURRENT_BRANCH" if git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA$DIFF$CURRENT_SHA" 1>/dev/null 2>&1; then break From 8fb90ed7f6bf64bddf7f439ae07d60e4cb4489b2 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Mon, 12 Dec 2022 11:14:49 -0700 Subject: [PATCH 3/4] Update diff-sha.sh --- diff-sha.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/diff-sha.sh b/diff-sha.sh index f4ca3cb5..d8ef6d6b 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -205,6 +205,10 @@ else fi else PREVIOUS_SHA=$GITHUB_EVENT_PULL_REQUEST_BASE_SHA + + if ! git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA$DIFF$CURRENT_SHA" 1>/dev/null 2>&1; then + PREVIOUS_SHA=$(git merge-base "$PREVIOUS_SHA" "$CURRENT_SHA" 2>&1) && exit_status=$? || exit_status=$? + fi fi if [[ -z "$PREVIOUS_SHA" || "$PREVIOUS_SHA" == "$CURRENT_SHA" ]]; then @@ -217,10 +221,10 @@ else max_depth=$INPUT_MAX_FETCH_DEPTH for ((i=0; i/dev/null 2>&1; then break From d9be0ccb5e69da56f3db7a8c69bc5caab52f729c Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Mon, 12 Dec 2022 11:16:39 -0700 Subject: [PATCH 4/4] Update diff-sha.sh --- diff-sha.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diff-sha.sh b/diff-sha.sh index d8ef6d6b..cd31e541 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -224,7 +224,7 @@ else echo "Fetching $i commits..." # shellcheck disable=SC2086 - git fetch $EXTRA_ARGS -u --progress --deepen="$i" origin "$CURRENT_BRANCH" + git fetch $EXTRA_ARGS -u --progress --deepen="$i" origin +"$GITHUB_REF":refs/remotes/origin/"$CURRENT_BRANCH" if git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA$DIFF$CURRENT_SHA" 1>/dev/null 2>&1; then break