From 4d1ed48b497cee2c96f4f3f5342f0709d7acac28 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Thu, 15 Dec 2022 20:53:14 -0700 Subject: [PATCH 01/31] chore: update test dir --- test/test new.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test new.txt b/test/test new.txt index 9f4b6d8bfea..f717185e104 100644 --- a/test/test new.txt +++ b/test/test new.txt @@ -1 +1,2 @@ -This is a test file +This is a test file 1. +This is a test file 2. From aabcbcc8821cef2274f50f8533dd6774b8ffae1d Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Thu, 15 Dec 2022 21:01:23 -0700 Subject: [PATCH 02/31] Update diff-sha.sh --- diff-sha.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/diff-sha.sh b/diff-sha.sh index 5090dd2b0d2..6573d955b6b 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -227,7 +227,7 @@ 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") && exit_status=$? || exit_status=$? + PREVIOUS_SHA=$(git merge-base "$TARGET_BRANCH" "$CURRENT_SHA") && exit_status=$? || exit_status=$? fi fi @@ -249,7 +249,7 @@ else if git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA$DIFF$CURRENT_SHA" 1>/dev/null 2>&1; then break else - NEW_PREVIOUS_SHA=$(git merge-base --fork-point "$PREVIOUS_SHA" "$CURRENT_SHA") && exit_status=$? || exit_status=$? + NEW_PREVIOUS_SHA=$(git merge-base --fork-point "$TARGET_BRANCH" "$CURRENT_SHA") && exit_status=$? || exit_status=$? if [[ -n "$NEW_PREVIOUS_SHA" ]]; then PREVIOUS_SHA=$NEW_PREVIOUS_SHA From bdfc50c467b188c7d8a7c48f1c72ff2686be3850 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Thu, 15 Dec 2022 21:15:31 -0700 Subject: [PATCH 03/31] Update diff-sha.sh --- diff-sha.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/diff-sha.sh b/diff-sha.sh index 6573d955b6b..95d249b4a15 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -232,7 +232,7 @@ else fi if [[ -z "$PREVIOUS_SHA" || "$PREVIOUS_SHA" == "$CURRENT_SHA" ]]; then - PREVIOUS_SHA=$GITHUB_EVENT_PULL_REQUEST_BASE_SHA && exit_status=$? || exit_status=$? + PREVIOUS_SHA=$(git merge-base --fork-point "$TARGET_BRANCH" "$CURRENT_SHA") && exit_status=$? || exit_status=$? fi echo "::debug::Previous SHA: $PREVIOUS_SHA" @@ -248,12 +248,6 @@ else for ((i=0; i/dev/null 2>&1; then break - else - NEW_PREVIOUS_SHA=$(git merge-base --fork-point "$TARGET_BRANCH" "$CURRENT_SHA") && exit_status=$? || exit_status=$? - - if [[ -n "$NEW_PREVIOUS_SHA" ]]; then - PREVIOUS_SHA=$NEW_PREVIOUS_SHA - fi fi echo "Fetching $i commits..." From ca30b8500a1363d8538291625cf74676f18993a9 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Thu, 15 Dec 2022 21:33:16 -0700 Subject: [PATCH 04/31] Update diff-sha.sh --- diff-sha.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/diff-sha.sh b/diff-sha.sh index 95d249b4a15..5fa16a92fb2 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -227,12 +227,12 @@ 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 "$TARGET_BRANCH" "$CURRENT_SHA") && exit_status=$? || exit_status=$? + PREVIOUS_SHA=$(git merge-base --fork-point "$TARGET_BRANCH" "$CURRENT_BRANCH") && exit_status=$? || exit_status=$? fi fi if [[ -z "$PREVIOUS_SHA" || "$PREVIOUS_SHA" == "$CURRENT_SHA" ]]; then - PREVIOUS_SHA=$(git merge-base --fork-point "$TARGET_BRANCH" "$CURRENT_SHA") && exit_status=$? || exit_status=$? + PREVIOUS_SHA=$(git merge-base --fork-point "$TARGET_BRANCH" "$CURRENT_BRANCH") && exit_status=$? || exit_status=$? fi echo "::debug::Previous SHA: $PREVIOUS_SHA" From 19e86cc60b215a3601e6bb5a28702bce8265451d Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Thu, 15 Dec 2022 21:42:30 -0700 Subject: [PATCH 05/31] 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 5fa16a92fb2..503343d6226 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -165,7 +165,7 @@ else # shellcheck disable=SC2086 git fetch $EXTRA_ARGS -u --progress --depth=$(( GITHUB_EVENT_PULL_REQUEST_COMMITS + 1 )) origin +"$GITHUB_REF":refs/remotes/origin/"$CURRENT_BRANCH" 1>/dev/null 2>&1 - COMMON_ANCESTOR=$(git rev-list --first-parent --max-parents=0 --max-count=1 origin/"$CURRENT_BRANCH") && exit_status=$? || exit_status=$? + COMMON_ANCESTOR=$(git rev-list --ancestry-path "$CURRENT_BRANCH".."$TARGET_BRANCH") && exit_status=$? || exit_status=$? if [[ -z "$COMMON_ANCESTOR" ]]; then echo "::debug::Unable to locate a common ancestor for the current branch: $CURRENT_BRANCH" From 9f3cd20ba2677398d642a1ca03afa2d4caed8559 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Thu, 15 Dec 2022 21:52:03 -0700 Subject: [PATCH 06/31] Update diff-sha.sh --- diff-sha.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/diff-sha.sh b/diff-sha.sh index 503343d6226..c350625a644 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -227,12 +227,12 @@ 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 --fork-point "$TARGET_BRANCH" "$CURRENT_BRANCH") && exit_status=$? || exit_status=$? + PREVIOUS_SHA=$(git merge-base --fork-point "$TARGET_BRANCH" "$CURRENT_SHA") && exit_status=$? || exit_status=$? fi fi if [[ -z "$PREVIOUS_SHA" || "$PREVIOUS_SHA" == "$CURRENT_SHA" ]]; then - PREVIOUS_SHA=$(git merge-base --fork-point "$TARGET_BRANCH" "$CURRENT_BRANCH") && exit_status=$? || exit_status=$? + PREVIOUS_SHA=$(git merge-base --fork-point "$TARGET_BRANCH" "$CURRENT_SHA") && exit_status=$? || exit_status=$? fi echo "::debug::Previous SHA: $PREVIOUS_SHA" From 1d0bc9880cb79508c6777862baa780c5aa3e33c5 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Thu, 15 Dec 2022 21:53:52 -0700 Subject: [PATCH 07/31] Update diff-sha.sh --- diff-sha.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/diff-sha.sh b/diff-sha.sh index c350625a644..409041ed39c 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -165,7 +165,7 @@ else # shellcheck disable=SC2086 git fetch $EXTRA_ARGS -u --progress --depth=$(( GITHUB_EVENT_PULL_REQUEST_COMMITS + 1 )) origin +"$GITHUB_REF":refs/remotes/origin/"$CURRENT_BRANCH" 1>/dev/null 2>&1 - COMMON_ANCESTOR=$(git rev-list --ancestry-path "$CURRENT_BRANCH".."$TARGET_BRANCH") && exit_status=$? || exit_status=$? + COMMON_ANCESTOR=$(git rev-list --ancestry-path "$GITHUB_REF".."$TARGET_BRANCH") && exit_status=$? || exit_status=$? if [[ -z "$COMMON_ANCESTOR" ]]; then echo "::debug::Unable to locate a common ancestor for the current branch: $CURRENT_BRANCH" @@ -227,12 +227,12 @@ 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 --fork-point "$TARGET_BRANCH" "$CURRENT_SHA") && exit_status=$? || exit_status=$? + PREVIOUS_SHA=$(git merge-base --fork-point "$TARGET_BRANCH" "$GITHUB_REF") && exit_status=$? || exit_status=$? fi fi if [[ -z "$PREVIOUS_SHA" || "$PREVIOUS_SHA" == "$CURRENT_SHA" ]]; then - PREVIOUS_SHA=$(git merge-base --fork-point "$TARGET_BRANCH" "$CURRENT_SHA") && exit_status=$? || exit_status=$? + PREVIOUS_SHA=$(git merge-base --fork-point "$TARGET_BRANCH" "$GITHUB_REF") && exit_status=$? || exit_status=$? fi echo "::debug::Previous SHA: $PREVIOUS_SHA" From fd3e44b55637344b2116e10a35afb214489305af Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Thu, 15 Dec 2022 21:54:42 -0700 Subject: [PATCH 08/31] Update test new.txt --- test/test new.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/test/test new.txt b/test/test new.txt index f717185e104..30fecdb09de 100644 --- a/test/test new.txt +++ b/test/test new.txt @@ -1,2 +1 @@ This is a test file 1. -This is a test file 2. From 4bf8a029f79d484c68649a748099978baabb6ea1 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Thu, 15 Dec 2022 22:00:33 -0700 Subject: [PATCH 09/31] Update diff-sha.sh --- diff-sha.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/diff-sha.sh b/diff-sha.sh index 409041ed39c..9873d42439f 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -227,12 +227,12 @@ 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 --fork-point "$TARGET_BRANCH" "$GITHUB_REF") && exit_status=$? || exit_status=$? + PREVIOUS_SHA=$(git merge-base --fork-point "$TARGET_BRANCH" "$CURRENT_SHA") && exit_status=$? || exit_status=$? fi fi if [[ -z "$PREVIOUS_SHA" || "$PREVIOUS_SHA" == "$CURRENT_SHA" ]]; then - PREVIOUS_SHA=$(git merge-base --fork-point "$TARGET_BRANCH" "$GITHUB_REF") && exit_status=$? || exit_status=$? + PREVIOUS_SHA=$GITHUB_EVENT_PULL_REQUEST_BASE_SHA && exit_status=$? || exit_status=$? fi echo "::debug::Previous SHA: $PREVIOUS_SHA" From 7f75cdb50481f9cdeae33ba45ac2fbcb3a42fa90 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Thu, 15 Dec 2022 22:01:00 -0700 Subject: [PATCH 10/31] 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 9873d42439f..6740f40fd99 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -227,7 +227,7 @@ 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 --fork-point "$TARGET_BRANCH" "$CURRENT_SHA") && exit_status=$? || exit_status=$? + PREVIOUS_SHA=$(git merge-base "$TARGET_BRANCH" "$CURRENT_SHA") && exit_status=$? || exit_status=$? fi fi From 237b05158c7dd3dfae893d1228e8bce2e465dc90 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Thu, 15 Dec 2022 22:15:57 -0700 Subject: [PATCH 11/31] Update diff-sha.sh --- diff-sha.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/diff-sha.sh b/diff-sha.sh index 6740f40fd99..4821d106189 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -165,7 +165,7 @@ else # shellcheck disable=SC2086 git fetch $EXTRA_ARGS -u --progress --depth=$(( GITHUB_EVENT_PULL_REQUEST_COMMITS + 1 )) origin +"$GITHUB_REF":refs/remotes/origin/"$CURRENT_BRANCH" 1>/dev/null 2>&1 - COMMON_ANCESTOR=$(git rev-list --ancestry-path "$GITHUB_REF".."$TARGET_BRANCH") && exit_status=$? || exit_status=$? + COMMON_ANCESTOR=$(git merge-base --fork-point "$TARGET_BRANCH" HEAD) && exit_status=$? || exit_status=$? if [[ -z "$COMMON_ANCESTOR" ]]; then echo "::debug::Unable to locate a common ancestor for the current branch: $CURRENT_BRANCH" @@ -227,7 +227,7 @@ 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 "$TARGET_BRANCH" "$CURRENT_SHA") && exit_status=$? || exit_status=$? + PREVIOUS_SHA=$(git merge-base --fork-point "$TARGET_BRANCH" "$CURRENT_SHA") && exit_status=$? || exit_status=$? fi fi From 0a3cc94baa1f6e1eacc6183ff97e3bc30a0f08fb Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 16 Dec 2022 07:05:52 -0700 Subject: [PATCH 12/31] Update test new.txt --- test/test new.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test new.txt b/test/test new.txt index 30fecdb09de..6de7b8c69d6 100644 --- a/test/test new.txt +++ b/test/test new.txt @@ -1 +1 @@ -This is a test file 1. +This is a test file. From 2b49b75dcbedeba429b367f4fdf5924d26d1cbee Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 16 Dec 2022 07:17:10 -0700 Subject: [PATCH 13/31] Update diff-sha.sh --- diff-sha.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/diff-sha.sh b/diff-sha.sh index 4821d106189..ae65e35e56b 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -224,10 +224,10 @@ else if [[ "$INPUT_SINCE_LAST_REMOTE_COMMIT" == "true" ]]; then PREVIOUS_SHA=$GITHUB_EVENT_BEFORE else - PREVIOUS_SHA=$GITHUB_EVENT_PULL_REQUEST_BASE_SHA - + PREVIOUS_SHA=$(git merge-base --fork-point "$TARGET_BRANCH" "$CURRENT_SHA") && exit_status=$? || exit_status=$? + if ! git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA$DIFF$CURRENT_SHA" 1>/dev/null 2>&1; then - PREVIOUS_SHA=$(git merge-base --fork-point "$TARGET_BRANCH" "$CURRENT_SHA") && exit_status=$? || exit_status=$? + PREVIOUS_SHA=$GITHUB_EVENT_PULL_REQUEST_BASE_SHA fi fi From 40f3d5695f9708f982dcaf5bb92fb6e21bf6bef7 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 16 Dec 2022 07:26:20 -0700 Subject: [PATCH 14/31] Update diff-sha.sh --- diff-sha.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/diff-sha.sh b/diff-sha.sh index ae65e35e56b..dac16aab8a2 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -251,6 +251,14 @@ else fi echo "Fetching $i commits..." + + if [[ -z "$INPUT_BASE_SHA" ]]; then + NEW_PREVIOUS_SHA=$(git merge-base --fork-point "$TARGET_BRANCH" "$CURRENT_SHA") + + if [[ -n $NEW_PREVIOUS_SHA ]]; then + PREVIOUS_SHA=$NEW_PREVIOUS_SHA + fi + fi # shellcheck disable=SC2086 git fetch $EXTRA_ARGS -u --progress --deepen="$i" origin $TARGET_BRANCH $CURRENT_SHA 1>/dev/null 2>&1 From e034ba961f95633ea20807b5fb96beef80c91597 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 16 Dec 2022 07:26:48 -0700 Subject: [PATCH 15/31] 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 dac16aab8a2..ae3c669712c 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -255,7 +255,7 @@ else if [[ -z "$INPUT_BASE_SHA" ]]; then NEW_PREVIOUS_SHA=$(git merge-base --fork-point "$TARGET_BRANCH" "$CURRENT_SHA") - if [[ -n $NEW_PREVIOUS_SHA ]]; then + if [[ -n "$NEW_PREVIOUS_SHA" ]]; then PREVIOUS_SHA=$NEW_PREVIOUS_SHA fi fi From d4e4d24f9c664a113efef389b8c5b38d08ef3aab Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 16 Dec 2022 07:44:56 -0700 Subject: [PATCH 16/31] 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 ae3c669712c..6e438b55d4c 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -set -euo pipefail +set -exuo pipefail INITIAL_COMMIT="false" GITHUB_OUTPUT=${GITHUB_OUTPUT:-""} From 9bb7d28e709c334088dfffef03e930363bc87f71 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 16 Dec 2022 09:23:09 -0700 Subject: [PATCH 17/31] 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 6e438b55d4c..4386939aa21 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -245,7 +245,7 @@ else depth=$INPUT_FETCH_DEPTH max_depth=$INPUT_MAX_FETCH_DEPTH - for ((i=0; i/dev/null 2>&1; then break fi From 996300de86178460152fae22bd01ee444881a888 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 16 Dec 2022 09:43:12 -0700 Subject: [PATCH 18/31] 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 4386939aa21..eba8d470e6a 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -172,7 +172,7 @@ else else echo "::debug::Common ancestor: $COMMON_ANCESTOR" - DATE=$(git log --date=iso8601 --format=%cd "${COMMON_ANCESTOR}") + DATE=$(git log --max-count=1 --date=iso8601 --format=%cd "${COMMON_ANCESTOR}") if [[ -z "$DATE" ]]; then echo "::error::Unable to locate a date for the common ancestor: $COMMON_ANCESTOR" From 2e7b724f9a832b17794502179429325bfd2f5a36 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 16 Dec 2022 09:48:16 -0700 Subject: [PATCH 19/31] 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 eba8d470e6a..dfc3279d55e 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -172,7 +172,7 @@ else else echo "::debug::Common ancestor: $COMMON_ANCESTOR" - DATE=$(git log --max-count=1 --date=iso8601 --format=%cd "${COMMON_ANCESTOR}") + DATE=$(git show --date=iso8601 --format=%cd "$COMMON_ANCESTOR") if [[ -z "$DATE" ]]; then echo "::error::Unable to locate a date for the common ancestor: $COMMON_ANCESTOR" From e8733f64faa72757a8474b1bf0aba275965f2c19 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 16 Dec 2022 10:03:24 -0700 Subject: [PATCH 20/31] 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 dfc3279d55e..4dd61b08f5d 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -172,7 +172,7 @@ else else echo "::debug::Common ancestor: $COMMON_ANCESTOR" - DATE=$(git show --date=iso8601 --format=%cd "$COMMON_ANCESTOR") + DATE=$(git show --quiet --date=iso8601 --format=%cd "$COMMON_ANCESTOR") if [[ -z "$DATE" ]]; then echo "::error::Unable to locate a date for the common ancestor: $COMMON_ANCESTOR" From 7dd55804cf4256d459ec1948f2174bdeefd36d0d Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 16 Dec 2022 10:17:31 -0700 Subject: [PATCH 21/31] 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 4dd61b08f5d..47092ea7570 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -set -exuo pipefail +set -euo pipefail INITIAL_COMMIT="false" GITHUB_OUTPUT=${GITHUB_OUTPUT:-""} From 550a9723589bfb99df2d7dde168ef537de4de82d Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 16 Dec 2022 10:40:19 -0700 Subject: [PATCH 22/31] Update diff-sha.sh --- diff-sha.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/diff-sha.sh b/diff-sha.sh index 47092ea7570..d19c51731af 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -set -euo pipefail +set -euxo pipefail INITIAL_COMMIT="false" GITHUB_OUTPUT=${GITHUB_OUTPUT:-""} @@ -261,7 +261,7 @@ else fi # shellcheck disable=SC2086 - git fetch $EXTRA_ARGS -u --progress --deepen="$i" origin $TARGET_BRANCH $CURRENT_SHA 1>/dev/null 2>&1 + git fetch $EXTRA_ARGS -u --progress --deepen="$i" origin $TARGET_BRANCH $CURRENT_SHA 1>/dev/null 2>&1 || true done if ((i >= max_depth)); then From 41bac1e2f746c759e06c15d5d7f6b63e7229b481 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 16 Dec 2022 10:53:13 -0700 Subject: [PATCH 23/31] Update diff-sha.sh --- diff-sha.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/diff-sha.sh b/diff-sha.sh index d19c51731af..3da404aa887 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -249,8 +249,6 @@ else if git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA$DIFF$CURRENT_SHA" 1>/dev/null 2>&1; then break fi - - echo "Fetching $i commits..." if [[ -z "$INPUT_BASE_SHA" ]]; then NEW_PREVIOUS_SHA=$(git merge-base --fork-point "$TARGET_BRANCH" "$CURRENT_SHA") @@ -260,6 +258,8 @@ else fi fi + echo "Fetching $i commits..." + # shellcheck disable=SC2086 git fetch $EXTRA_ARGS -u --progress --deepen="$i" origin $TARGET_BRANCH $CURRENT_SHA 1>/dev/null 2>&1 || true done From acd99f22a76390e8a64d0125d07d220bd96cf970 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 16 Dec 2022 10:53:49 -0700 Subject: [PATCH 24/31] 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 3da404aa887..7c51a5ed999 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -245,7 +245,7 @@ else depth=$INPUT_FETCH_DEPTH max_depth=$INPUT_MAX_FETCH_DEPTH - for ((i=0; i/dev/null 2>&1; then break fi From f701d66cbd44011378b1d84fe013a79fc178a12d Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 16 Dec 2022 11:15:14 -0700 Subject: [PATCH 25/31] Update diff-sha.sh --- diff-sha.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/diff-sha.sh b/diff-sha.sh index 7c51a5ed999..53649057cdf 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -224,7 +224,11 @@ else if [[ "$INPUT_SINCE_LAST_REMOTE_COMMIT" == "true" ]]; then PREVIOUS_SHA=$GITHUB_EVENT_BEFORE else - PREVIOUS_SHA=$(git merge-base --fork-point "$TARGET_BRANCH" "$CURRENT_SHA") && exit_status=$? || exit_status=$? + PREVIOUS_SHA=${COMMON_ANCESTOR:-} + + if [[ -z "$PREVIOUS_SHA" ]]; then + PREVIOUS_SHA=$GITHUB_EVENT_PULL_REQUEST_BASE_SHA && exit_status=$? || exit_status=$? + fi if ! git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA$DIFF$CURRENT_SHA" 1>/dev/null 2>&1; then PREVIOUS_SHA=$GITHUB_EVENT_PULL_REQUEST_BASE_SHA From e070e451a6caa332855fa487fce4419fb0faa1c9 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 16 Dec 2022 11:16:00 -0700 Subject: [PATCH 26/31] 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 53649057cdf..26de410f2f1 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -265,7 +265,7 @@ else echo "Fetching $i commits..." # shellcheck disable=SC2086 - git fetch $EXTRA_ARGS -u --progress --deepen="$i" origin $TARGET_BRANCH $CURRENT_SHA 1>/dev/null 2>&1 || true + git fetch $EXTRA_ARGS -u --progress --deepen="$i" origin $TARGET_BRANCH $CURRENT_SHA 1>/dev/null 2>&1 done if ((i >= max_depth)); then From c3ab8f39360d3f76fe2a84d479387334fcaf5516 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 16 Dec 2022 11:18:16 -0700 Subject: [PATCH 27/31] 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 26de410f2f1..05008d838ac 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -249,7 +249,7 @@ else depth=$INPUT_FETCH_DEPTH max_depth=$INPUT_MAX_FETCH_DEPTH - for ((i=depth; imax_depth; i+=depth)); do if git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA$DIFF$CURRENT_SHA" 1>/dev/null 2>&1; then break fi From 78ac3f4d78dd914e323a41190be5db9eb188cdaa Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 16 Dec 2022 11:29:04 -0700 Subject: [PATCH 28/31] Update diff-sha.sh --- diff-sha.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/diff-sha.sh b/diff-sha.sh index 05008d838ac..db09f0c97de 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -249,7 +249,7 @@ else depth=$INPUT_FETCH_DEPTH max_depth=$INPUT_MAX_FETCH_DEPTH - for ((i=depth; i>max_depth; i+=depth)); do + for ((i=20; i/dev/null 2>&1; then break fi @@ -267,8 +267,8 @@ else # shellcheck disable=SC2086 git fetch $EXTRA_ARGS -u --progress --deepen="$i" origin $TARGET_BRANCH $CURRENT_SHA 1>/dev/null 2>&1 done - - if ((i >= max_depth)); then + + 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 From 4837447a0b8205aa7b0fbea6291cb9ab5183ae81 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 16 Dec 2022 11:29:59 -0700 Subject: [PATCH 29/31] Update diff-sha.sh --- diff-sha.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/diff-sha.sh b/diff-sha.sh index db09f0c97de..fbc2dc1a2b2 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -266,17 +266,16 @@ 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 fi - echo "::debug::Target branch: $TARGET_BRANCH" echo "::debug::Current branch: $CURRENT_BRANCH" From 675839364538318b9e2272dcb40faaf6bbb4d91f Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 16 Dec 2022 11:34:44 -0700 Subject: [PATCH 30/31] Update action.yml --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 86cc8e7059e..998c2b39d47 100644 --- a/action.yml +++ b/action.yml @@ -87,7 +87,7 @@ inputs: max_fetch_depth: description: "Maximum depth of the branch history fetched. **NOTE**: This can be adjusted to resolve errors with insufficient history." required: false - default: "6000" + default: "9000" since_last_remote_commit: description: "Use the last commit on the remote branch as the `base_sha`. Defaults to the last non merge commit on the target branch for pull request events and the previous remote commit of the current branch for push events." required: true From 10aaa531b8c03522fcf7eef2eef612396dfce0c9 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 16 Dec 2022 11:49:36 -0700 Subject: [PATCH 31/31] 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 fbc2dc1a2b2..66916abfa92 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -255,7 +255,7 @@ else fi if [[ -z "$INPUT_BASE_SHA" ]]; then - NEW_PREVIOUS_SHA=$(git merge-base --fork-point "$TARGET_BRANCH" "$CURRENT_SHA") + NEW_PREVIOUS_SHA=$(git merge-base --fork-point "$TARGET_BRANCH" "$CURRENT_SHA") && exit_status=$? || exit_status=$? if [[ -n "$NEW_PREVIOUS_SHA" ]]; then PREVIOUS_SHA=$NEW_PREVIOUS_SHA