From c7d3f5f08e4e6de53b73747f46c6135ac64045f3 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Thu, 16 Feb 2023 05:27:58 -0700 Subject: [PATCH 1/5] fix: bug with fetching history --- diff-sha.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diff-sha.sh b/diff-sha.sh index f8827ae119d..7243f7f030d 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 f72b269c5676445b3097259bddc6d3f7c4b56cde Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Thu, 16 Feb 2023 05:56:27 -0700 Subject: [PATCH 2/5] 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 7243f7f030d..753c33b6117 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -60,7 +60,7 @@ if [[ -z $GITHUB_EVENT_PULL_REQUEST_BASE_REF ]]; then if [[ -f .git/shallow ]]; then echo "Fetching remote refs..." # shellcheck disable=SC2086 - git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" origin +refs/heads/"$CURRENT_BRANCH":refs/remotes/origin/"$CURRENT_BRANCH" 1>/dev/null + git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" origin "$CURRENT_BRANCH" 1>/dev/null || true # shellcheck disable=SC2086 git submodule foreach git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" || true fi From 31b47f66ab4e8d9aba92860e7fce84c7dfc86a4f Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Thu, 16 Feb 2023 06:05:38 -0700 Subject: [PATCH 3/5] 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 753c33b6117..89474d49066 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -57,10 +57,10 @@ if [[ -z $GITHUB_EVENT_PULL_REQUEST_BASE_REF ]]; then TARGET_BRANCH=$GITHUB_REFNAME CURRENT_BRANCH=$TARGET_BRANCH - if [[ -f .git/shallow ]]; then + if git rev-parse --is-shallow-repository; then echo "Fetching remote refs..." # shellcheck disable=SC2086 - git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" origin "$CURRENT_BRANCH" 1>/dev/null || true + git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" origin +refs/heads/"$CURRENT_BRANCH":refs/remotes/origin/"$CURRENT_BRANCH" 1>/dev/null # shellcheck disable=SC2086 git submodule foreach git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" || true fi @@ -162,7 +162,7 @@ else TARGET_BRANCH=$CURRENT_BRANCH fi - if [[ -f .git/shallow ]]; then + if git rev-parse --is-shallow-repository; then echo "Fetching remote refs..." # shellcheck disable=SC2086 git fetch $EXTRA_ARGS -u --progress origin pull/"$GITHUB_EVENT_PULL_REQUEST_NUMBER"/head:"$CURRENT_BRANCH" 1>/dev/null From 228e374be4bb15749b74dbedcabc3eb57ed2c397 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Thu, 16 Feb 2023 06:06:26 -0700 Subject: [PATCH 4/5] 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 89474d49066..1f8698c96db 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -213,7 +213,7 @@ else else PREVIOUS_SHA=$(git rev-parse origin/"$TARGET_BRANCH") && exit_status=$? || exit_status=$? - if [[ -f .git/shallow ]]; then + if git rev-parse --is-shallow-repository; 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 echo "::debug::Merge base is not in the local history, fetching remote target branch..." From cc05f83fb40a737ad01b2fe0a1f204b6ab24cc84 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Thu, 16 Feb 2023 06:10:21 -0700 Subject: [PATCH 5/5] 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 1f8698c96db..11241844d5f 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -57,7 +57,7 @@ if [[ -z $GITHUB_EVENT_PULL_REQUEST_BASE_REF ]]; then TARGET_BRANCH=$GITHUB_REFNAME CURRENT_BRANCH=$TARGET_BRANCH - if git rev-parse --is-shallow-repository; then + if $(git rev-parse --is-shallow-repository); then echo "Fetching remote refs..." # shellcheck disable=SC2086 git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" origin +refs/heads/"$CURRENT_BRANCH":refs/remotes/origin/"$CURRENT_BRANCH" 1>/dev/null @@ -162,7 +162,7 @@ else TARGET_BRANCH=$CURRENT_BRANCH fi - if git rev-parse --is-shallow-repository; then + if $(git rev-parse --is-shallow-repository); then echo "Fetching remote refs..." # shellcheck disable=SC2086 git fetch $EXTRA_ARGS -u --progress origin pull/"$GITHUB_EVENT_PULL_REQUEST_NUMBER"/head:"$CURRENT_BRANCH" 1>/dev/null @@ -213,7 +213,7 @@ else else PREVIOUS_SHA=$(git rev-parse origin/"$TARGET_BRANCH") && exit_status=$? || exit_status=$? - if git rev-parse --is-shallow-repository; then + if $(git rev-parse --is-shallow-repository); 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 echo "::debug::Merge base is not in the local history, fetching remote target branch..."