From b94eca1419f00612eb632ed051e7536ff58a6f5b Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 4 Nov 2022 11:40:18 -0600 Subject: [PATCH 01/20] chore: update test --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 721c82be..3cfbbf57 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -425,7 +425,7 @@ jobs: exit 1 shell: bash - - name: Run changed-files with dir_names + - name: Run changed-files with dir_names specific id: changed-files-dir-names-specific uses: ./ with: From 6079b26874d9e543aa4e5112d041b438a09de2e1 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 4 Nov 2022 11:40:44 -0600 Subject: [PATCH 02/20] 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 417ed52c..7eb433b0 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -set -euxo pipefail +set -euo pipefail INITIAL_COMMIT="false" GITHUB_OUTPUT=${GITHUB_OUTPUT:-""} From 84396edc7e420f29bbba09e21c613457cbe6ad5b Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 4 Nov 2022 11:54:46 -0600 Subject: [PATCH 03/20] Update diff-sha.sh --- diff-sha.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/diff-sha.sh b/diff-sha.sh index 7eb433b0..af1180b1 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -56,7 +56,7 @@ if [[ -z $GITHUB_BASE_REF ]]; then if [[ -z $INPUT_SHA ]]; then CURRENT_SHA=$(git rev-list -n 1 HEAD 2>&1) && exit_status=$? || exit_status=$? else - git fetch --no-tags -u --progress --deepen="$INPUT_FETCH_DEPTH" + git fetch --no-tags -u --progress --depth="$INPUT_FETCH_DEPTH" "$CURRENT_BRANCH":"$CURRENT_BRANCH" CURRENT_SHA=$INPUT_SHA; exit_status=$? fi fi @@ -82,7 +82,7 @@ if [[ -z $GITHUB_BASE_REF ]]; then exit 1 fi else - git fetch --no-tags -u --progress --deepen="$INPUT_FETCH_DEPTH" + git fetch --no-tags -u --progress --depth="$INPUT_FETCH_DEPTH" "$CURRENT_BRANCH":"$CURRENT_BRANCH" PREVIOUS_SHA=$(git rev-list -n 1 "$TARGET_BRANCH" 2>&1) && exit_status=$? || exit_status=$? if [[ -z "$PREVIOUS_SHA" ]]; then @@ -111,10 +111,10 @@ if [[ -z $GITHUB_BASE_REF ]]; then fi fi else - git fetch --no-tags -u --progress --deepen="$INPUT_FETCH_DEPTH" PREVIOUS_SHA=$INPUT_BASE_SHA TARGET_BRANCH=$(git name-rev --name-only "$PREVIOUS_SHA" 2>&1) && exit_status=$? || exit_status=$? CURRENT_BRANCH=$TARGET_BRANCH + git fetch --no-tags -u --progress --depth="$INPUT_FETCH_DEPTH" "$CURRENT_BRANCH":"$CURRENT_BRANCH" fi echo "::debug::Target branch $TARGET_BRANCH..." @@ -134,7 +134,7 @@ else CURRENT_BRANCH=$GITHUB_HEAD_REF echo "Fetching remote refs..." - git fetch --no-tags -u --progress --deepen=40000 origin "$CURRENT_BRANCH":"$CURRENT_BRANCH" + git fetch --no-tags -u --progress --depth=40000 origin "$CURRENT_BRANCH":"$CURRENT_BRANCH" git fetch --no-tags -u --progress --depth="$INPUT_FETCH_DEPTH" origin "$TARGET_BRANCH":"$TARGET_BRANCH" echo "::debug::Getting HEAD SHA..." From dd6f3c9e10b7d2a235e0ade60152bab8721a9d1c Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 4 Nov 2022 12:02:58 -0600 Subject: [PATCH 04/20] 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 af1180b1..5daf90c8 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -56,7 +56,7 @@ if [[ -z $GITHUB_BASE_REF ]]; then if [[ -z $INPUT_SHA ]]; then CURRENT_SHA=$(git rev-list -n 1 HEAD 2>&1) && exit_status=$? || exit_status=$? else - git fetch --no-tags -u --progress --depth="$INPUT_FETCH_DEPTH" "$CURRENT_BRANCH":"$CURRENT_BRANCH" + git fetch --no-tags -u --progress --depth="$INPUT_FETCH_DEPTH" origin "$CURRENT_BRANCH":"$CURRENT_BRANCH" CURRENT_SHA=$INPUT_SHA; exit_status=$? fi fi @@ -82,7 +82,7 @@ if [[ -z $GITHUB_BASE_REF ]]; then exit 1 fi else - git fetch --no-tags -u --progress --depth="$INPUT_FETCH_DEPTH" "$CURRENT_BRANCH":"$CURRENT_BRANCH" + git fetch --no-tags -u --progress --depth="$INPUT_FETCH_DEPTH" origin "$CURRENT_BRANCH":"$CURRENT_BRANCH" PREVIOUS_SHA=$(git rev-list -n 1 "$TARGET_BRANCH" 2>&1) && exit_status=$? || exit_status=$? if [[ -z "$PREVIOUS_SHA" ]]; then @@ -114,7 +114,7 @@ if [[ -z $GITHUB_BASE_REF ]]; then PREVIOUS_SHA=$INPUT_BASE_SHA TARGET_BRANCH=$(git name-rev --name-only "$PREVIOUS_SHA" 2>&1) && exit_status=$? || exit_status=$? CURRENT_BRANCH=$TARGET_BRANCH - git fetch --no-tags -u --progress --depth="$INPUT_FETCH_DEPTH" "$CURRENT_BRANCH":"$CURRENT_BRANCH" + git fetch --no-tags -u --progress --depth="$INPUT_FETCH_DEPTH" origin "$CURRENT_BRANCH":"$CURRENT_BRANCH" fi echo "::debug::Target branch $TARGET_BRANCH..." From ae5f0327740921ed20ebcc52e988e0b442a5682d Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 4 Nov 2022 12:09:42 -0600 Subject: [PATCH 05/20] Update diff-sha.sh --- diff-sha.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/diff-sha.sh b/diff-sha.sh index 5daf90c8..a8784a78 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -41,6 +41,7 @@ fi if [[ -z $GITHUB_BASE_REF ]]; then echo "Running on a push event..." TARGET_BRANCH=${GITHUB_REF/refs\/heads\//} && exit_status=$? || exit_status=$? + TARGET_BRANCH=${TARGET_BRANCH/refs\/tags\//} CURRENT_BRANCH=$TARGET_BRANCH && exit_status=$? || exit_status=$? echo "::debug::Getting HEAD SHA..." From 251c03879aca6641a1a76ca0deb05ab5ba242d23 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 4 Nov 2022 12:10:09 -0600 Subject: [PATCH 06/20] 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 a8784a78..241b2d7d 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -41,7 +41,7 @@ fi if [[ -z $GITHUB_BASE_REF ]]; then echo "Running on a push event..." TARGET_BRANCH=${GITHUB_REF/refs\/heads\//} && exit_status=$? || exit_status=$? - TARGET_BRANCH=${TARGET_BRANCH/refs\/tags\//} + TARGET_BRANCH=${TARGET_BRANCH/refs\/tags\//} && exit_status=$? || exit_status=$? CURRENT_BRANCH=$TARGET_BRANCH && exit_status=$? || exit_status=$? echo "::debug::Getting HEAD SHA..." From 90a4d2a19ba21c5033e6ad86d19548c728993fa0 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 4 Nov 2022 12:12:26 -0600 Subject: [PATCH 07/20] 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 241b2d7d..6c33de94 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -57,7 +57,7 @@ if [[ -z $GITHUB_BASE_REF ]]; then if [[ -z $INPUT_SHA ]]; then CURRENT_SHA=$(git rev-list -n 1 HEAD 2>&1) && exit_status=$? || exit_status=$? else - git fetch --no-tags -u --progress --depth="$INPUT_FETCH_DEPTH" origin "$CURRENT_BRANCH":"$CURRENT_BRANCH" + git fetch --no-tags -u --progress --deepen="$INPUT_FETCH_DEPTH" origin "$CURRENT_BRANCH":"$CURRENT_BRANCH" CURRENT_SHA=$INPUT_SHA; exit_status=$? fi fi @@ -83,7 +83,7 @@ if [[ -z $GITHUB_BASE_REF ]]; then exit 1 fi else - git fetch --no-tags -u --progress --depth="$INPUT_FETCH_DEPTH" origin "$CURRENT_BRANCH":"$CURRENT_BRANCH" + git fetch --no-tags -u --progress --deepen="$INPUT_FETCH_DEPTH" origin "$CURRENT_BRANCH":"$CURRENT_BRANCH" PREVIOUS_SHA=$(git rev-list -n 1 "$TARGET_BRANCH" 2>&1) && exit_status=$? || exit_status=$? if [[ -z "$PREVIOUS_SHA" ]]; then @@ -115,7 +115,7 @@ if [[ -z $GITHUB_BASE_REF ]]; then PREVIOUS_SHA=$INPUT_BASE_SHA TARGET_BRANCH=$(git name-rev --name-only "$PREVIOUS_SHA" 2>&1) && exit_status=$? || exit_status=$? CURRENT_BRANCH=$TARGET_BRANCH - git fetch --no-tags -u --progress --depth="$INPUT_FETCH_DEPTH" origin "$CURRENT_BRANCH":"$CURRENT_BRANCH" + git fetch --no-tags -u --progress --deepen="$INPUT_FETCH_DEPTH" origin "$CURRENT_BRANCH":"$CURRENT_BRANCH" fi echo "::debug::Target branch $TARGET_BRANCH..." From 3e8708a68459aa9a34c10a846402235eb5b22440 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 4 Nov 2022 12:28:22 -0600 Subject: [PATCH 08/20] Update diff-sha.sh --- diff-sha.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/diff-sha.sh b/diff-sha.sh index 6c33de94..b9913e1a 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -57,7 +57,6 @@ if [[ -z $GITHUB_BASE_REF ]]; then if [[ -z $INPUT_SHA ]]; then CURRENT_SHA=$(git rev-list -n 1 HEAD 2>&1) && exit_status=$? || exit_status=$? else - git fetch --no-tags -u --progress --deepen="$INPUT_FETCH_DEPTH" origin "$CURRENT_BRANCH":"$CURRENT_BRANCH" CURRENT_SHA=$INPUT_SHA; exit_status=$? fi fi @@ -83,7 +82,6 @@ if [[ -z $GITHUB_BASE_REF ]]; then exit 1 fi else - git fetch --no-tags -u --progress --deepen="$INPUT_FETCH_DEPTH" origin "$CURRENT_BRANCH":"$CURRENT_BRANCH" PREVIOUS_SHA=$(git rev-list -n 1 "$TARGET_BRANCH" 2>&1) && exit_status=$? || exit_status=$? if [[ -z "$PREVIOUS_SHA" ]]; then @@ -115,7 +113,6 @@ if [[ -z $GITHUB_BASE_REF ]]; then PREVIOUS_SHA=$INPUT_BASE_SHA TARGET_BRANCH=$(git name-rev --name-only "$PREVIOUS_SHA" 2>&1) && exit_status=$? || exit_status=$? CURRENT_BRANCH=$TARGET_BRANCH - git fetch --no-tags -u --progress --deepen="$INPUT_FETCH_DEPTH" origin "$CURRENT_BRANCH":"$CURRENT_BRANCH" fi echo "::debug::Target branch $TARGET_BRANCH..." @@ -135,8 +132,7 @@ else CURRENT_BRANCH=$GITHUB_HEAD_REF echo "Fetching remote refs..." - git fetch --no-tags -u --progress --depth=40000 origin "$CURRENT_BRANCH":"$CURRENT_BRANCH" - git fetch --no-tags -u --progress --depth="$INPUT_FETCH_DEPTH" origin "$TARGET_BRANCH":"$TARGET_BRANCH" + git fetch --no-tags -u --progress --depth="$INPUT_FETCH_DEPTH" origin "$TARGET_BRANCH" echo "::debug::Getting HEAD SHA..." if [[ -n "$INPUT_UNTIL" ]]; then @@ -175,6 +171,14 @@ else else PREVIOUS_SHA=$INPUT_BASE_SHA && exit_status=$? || exit_status=$? fi + + depth=50 + + while ! git merge-base "$PREVIOUS_SHA" "$CURRENT_SHA" > /dev/null; do + depth=$((depth+1024)) + git fetch --depth=$depth origin "$CURRENT_BRANCH" + git fetch --depth=$depth origin "$TARGET_BRANCH" + done echo "::debug::Target branch: $TARGET_BRANCH" echo "::debug::Current branch: $CURRENT_BRANCH" From 133f857c904346c8c8c0b1db5055f4dd6fe09d6b Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 4 Nov 2022 13:07:40 -0600 Subject: [PATCH 09/20] Update diff-sha.sh --- diff-sha.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/diff-sha.sh b/diff-sha.sh index b9913e1a..98fed43c 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -57,6 +57,7 @@ if [[ -z $GITHUB_BASE_REF ]]; then if [[ -z $INPUT_SHA ]]; then CURRENT_SHA=$(git rev-list -n 1 HEAD 2>&1) && exit_status=$? || exit_status=$? else + git fetch --no-tags -u --progress --deepen="$INPUT_FETCH_DEPTH" CURRENT_SHA=$INPUT_SHA; exit_status=$? fi fi @@ -110,6 +111,7 @@ if [[ -z $GITHUB_BASE_REF ]]; then fi fi else + git fetch --no-tags -u --progress --deepen="$INPUT_FETCH_DEPTH" PREVIOUS_SHA=$INPUT_BASE_SHA TARGET_BRANCH=$(git name-rev --name-only "$PREVIOUS_SHA" 2>&1) && exit_status=$? || exit_status=$? CURRENT_BRANCH=$TARGET_BRANCH @@ -172,12 +174,18 @@ else PREVIOUS_SHA=$INPUT_BASE_SHA && exit_status=$? || exit_status=$? fi - depth=50 + depth=$INPUT_FETCH_DEPTH - while ! git merge-base "$PREVIOUS_SHA" "$CURRENT_SHA" > /dev/null; do + while ! git merge-base $TARGET_BRANCH $CURRENT_BRANCH > /dev/null; do depth=$((depth+1024)) - git fetch --depth=$depth origin "$CURRENT_BRANCH" - git fetch --depth=$depth origin "$TARGET_BRANCH" + + git fetch -q --deepen=$depth origin "$TARGET_BRANCH" "$CURRENT_BRANCH" + + if [[ $depth -gt 5000 ]]; + echo "::error::Unable to locate the merge-base for: $TARGET_BRANCH $CURRENT_BRANCH" + echo "::error::Please verify that both commits are valid, and increase the fetch_depth to a number higher than $INPUT_FETCH_DEPTH." + exit 1 + then done echo "::debug::Target branch: $TARGET_BRANCH" From ac72938f3a87db3b5a54c1fb3149221032abc6da Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 4 Nov 2022 14:17:10 -0600 Subject: [PATCH 10/20] 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 98fed43c..df0070f9 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -179,13 +179,13 @@ else while ! git merge-base $TARGET_BRANCH $CURRENT_BRANCH > /dev/null; do depth=$((depth+1024)) - git fetch -q --deepen=$depth origin "$TARGET_BRANCH" "$CURRENT_BRANCH" + git fetch -q --deepen=$depth origin "$CURRENT_BRANCH":"$CURRENT_BRANCH" - if [[ $depth -gt 5000 ]]; + if [[ $depth -gt 5000 ]]; then echo "::error::Unable to locate the merge-base for: $TARGET_BRANCH $CURRENT_BRANCH" echo "::error::Please verify that both commits are valid, and increase the fetch_depth to a number higher than $INPUT_FETCH_DEPTH." exit 1 - then + fi done echo "::debug::Target branch: $TARGET_BRANCH" From 97e67238eae0caff43977a1e616f2dc83c476015 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 4 Nov 2022 14:22:55 -0600 Subject: [PATCH 11/20] Update diff-sha.sh Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- diff-sha.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diff-sha.sh b/diff-sha.sh index df0070f9..0ba52db7 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -176,7 +176,7 @@ else depth=$INPUT_FETCH_DEPTH - while ! git merge-base $TARGET_BRANCH $CURRENT_BRANCH > /dev/null; do + while ! git merge-base "$TARGET_BRANCH" "$CURRENT_BRANCH" > /dev/null; do depth=$((depth+1024)) git fetch -q --deepen=$depth origin "$CURRENT_BRANCH":"$CURRENT_BRANCH" From dc104b5c83b2820110d3429d53d2b44dcc97b622 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 4 Nov 2022 14:25:33 -0600 Subject: [PATCH 12/20] Update diff-sha.sh --- diff-sha.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/diff-sha.sh b/diff-sha.sh index 0ba52db7..5ff4e13c 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -41,7 +41,6 @@ fi if [[ -z $GITHUB_BASE_REF ]]; then echo "Running on a push event..." TARGET_BRANCH=${GITHUB_REF/refs\/heads\//} && exit_status=$? || exit_status=$? - TARGET_BRANCH=${TARGET_BRANCH/refs\/tags\//} && exit_status=$? || exit_status=$? CURRENT_BRANCH=$TARGET_BRANCH && exit_status=$? || exit_status=$? echo "::debug::Getting HEAD SHA..." From 0f093899546dc124d6442629337ac74e38608588 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 4 Nov 2022 14:41:40 -0600 Subject: [PATCH 13/20] 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 5ff4e13c..f2bd7687 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -177,8 +177,12 @@ else while ! git merge-base "$TARGET_BRANCH" "$CURRENT_BRANCH" > /dev/null; do depth=$((depth+1024)) - - git fetch -q --deepen=$depth origin "$CURRENT_BRANCH":"$CURRENT_BRANCH" + + if [[ -d .git/shallow ]]; then + git fetch -q --deepth=$depth --unshallow origin "$CURRENT_BRANCH":"$CURRENT_BRANCH" + else + git fetch -q --deepth=$depth origin "$CURRENT_BRANCH":"$CURRENT_BRANCH" + fi if [[ $depth -gt 5000 ]]; then echo "::error::Unable to locate the merge-base for: $TARGET_BRANCH $CURRENT_BRANCH" From 958d453c5dd1aafb07e10aed3287a11e807548c9 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 4 Nov 2022 14:43:22 -0600 Subject: [PATCH 14/20] 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 f2bd7687..8dd0200c 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -178,10 +178,10 @@ else while ! git merge-base "$TARGET_BRANCH" "$CURRENT_BRANCH" > /dev/null; do depth=$((depth+1024)) - if [[ -d .git/shallow ]]; then - git fetch -q --deepth=$depth --unshallow origin "$CURRENT_BRANCH":"$CURRENT_BRANCH" + if [[ -f .git/shallow ]]; then + git fetch -q --deepen=$depth origin "$CURRENT_BRANCH":"$CURRENT_BRANCH" else - git fetch -q --deepth=$depth origin "$CURRENT_BRANCH":"$CURRENT_BRANCH" + git fetch -q --depth=$depth origin "$CURRENT_BRANCH":"$CURRENT_BRANCH" fi if [[ $depth -gt 5000 ]]; then From a3a62da413fdbe8d9e79d6ed5d8c8d0899d23bc8 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 4 Nov 2022 14:49:06 -0600 Subject: [PATCH 15/20] 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 8dd0200c..ec402307 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:-""} From 2982c7c1d09070c10d533dd14d195c1793bbbfd4 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 4 Nov 2022 15:06:44 -0600 Subject: [PATCH 16/20] Update diff-sha.sh --- diff-sha.sh | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/diff-sha.sh b/diff-sha.sh index ec402307..b3a90ff1 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -133,7 +133,13 @@ else CURRENT_BRANCH=$GITHUB_HEAD_REF echo "Fetching remote refs..." - git fetch --no-tags -u --progress --depth="$INPUT_FETCH_DEPTH" origin "$TARGET_BRANCH" + + git fetch --depth="$INPUT_FETCH_DEPTH" origin +refs/heads/"$TARGET_BRANCH":refs/remotes/origin/"$TARGET_BRANCH" + git branch --track "$TARGET_BRANCH" origin/"$TARGET_BRANCH" + + while [ -z $( git merge-base "$TARGET_BRANCH" HEAD ) ]; do + git fetch --deepen="$INPUT_FETCH_DEPTH" origin "$TARGET_BRANCH" HEAD; + done echo "::debug::Getting HEAD SHA..." if [[ -n "$INPUT_UNTIL" ]]; then @@ -172,24 +178,6 @@ else else PREVIOUS_SHA=$INPUT_BASE_SHA && exit_status=$? || exit_status=$? fi - - depth=$INPUT_FETCH_DEPTH - - while ! git merge-base "$TARGET_BRANCH" "$CURRENT_BRANCH" > /dev/null; do - depth=$((depth+1024)) - - if [[ -f .git/shallow ]]; then - git fetch -q --deepen=$depth origin "$CURRENT_BRANCH":"$CURRENT_BRANCH" - else - git fetch -q --depth=$depth origin "$CURRENT_BRANCH":"$CURRENT_BRANCH" - fi - - if [[ $depth -gt 5000 ]]; then - echo "::error::Unable to locate the merge-base for: $TARGET_BRANCH $CURRENT_BRANCH" - echo "::error::Please verify that both commits are valid, and increase the fetch_depth to a number higher than $INPUT_FETCH_DEPTH." - exit 1 - fi - done echo "::debug::Target branch: $TARGET_BRANCH" echo "::debug::Current branch: $CURRENT_BRANCH" From 6ac10877755a1de4bd5f14d1616007c1fd51a999 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 4 Nov 2022 15:09:11 -0600 Subject: [PATCH 17/20] 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 b3a90ff1..68487144 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -135,9 +135,9 @@ else echo "Fetching remote refs..." git fetch --depth="$INPUT_FETCH_DEPTH" origin +refs/heads/"$TARGET_BRANCH":refs/remotes/origin/"$TARGET_BRANCH" - git branch --track "$TARGET_BRANCH" origin/"$TARGET_BRANCH" + git branch --track "$TARGET_BRANCH" origin/"$TARGET_BRANCH" || true - while [ -z $( git merge-base "$TARGET_BRANCH" HEAD ) ]; do + while [ -z "$( git merge-base "$TARGET_BRANCH" HEAD )" ]; do git fetch --deepen="$INPUT_FETCH_DEPTH" origin "$TARGET_BRANCH" HEAD; done From 367c547d7d8b6e7e574cb34a2ce3800072db4044 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 4 Nov 2022 15:21:49 -0600 Subject: [PATCH 18/20] 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 68487144..ef7428a8 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -set -euxo pipefail +set -euo pipefail INITIAL_COMMIT="false" GITHUB_OUTPUT=${GITHUB_OUTPUT:-""} From 5b43f918391d796bc464cb0cbd537cbe75d3a4ea Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 4 Nov 2022 16:31:48 -0600 Subject: [PATCH 19/20] Update diff-sha.sh --- diff-sha.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/diff-sha.sh b/diff-sha.sh index ef7428a8..190c1cc1 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -137,8 +137,16 @@ else git fetch --depth="$INPUT_FETCH_DEPTH" origin +refs/heads/"$TARGET_BRANCH":refs/remotes/origin/"$TARGET_BRANCH" git branch --track "$TARGET_BRANCH" origin/"$TARGET_BRANCH" || true + depth=$INPUT_FETCH_DEPTH + while [ -z "$( git merge-base "$TARGET_BRANCH" HEAD )" ]; do - git fetch --deepen="$INPUT_FETCH_DEPTH" origin "$TARGET_BRANCH" HEAD; + git fetch --deepen="$depth" origin "$TARGET_BRANCH" HEAD; + depth=$((depth * 10)) + max_depth=3000 + + if [[ $depth -gt $max_depth ]]; then + echo "::error::Unable to find merge-base of $TARGET_BRANCH and HEAD." + fi done echo "::debug::Getting HEAD SHA..." From ac593b977e96083c4929efa48bb05633afed835c Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 4 Nov 2022 16:40:47 -0600 Subject: [PATCH 20/20] 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 190c1cc1..ba69cf4f 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -142,7 +142,7 @@ else while [ -z "$( git merge-base "$TARGET_BRANCH" HEAD )" ]; do git fetch --deepen="$depth" origin "$TARGET_BRANCH" HEAD; depth=$((depth * 10)) - max_depth=3000 + max_depth=5000 if [[ $depth -gt $max_depth ]]; then echo "::error::Unable to find merge-base of $TARGET_BRANCH and HEAD."