Skip to content

Commit

Permalink
fix: bug with fetching history (#989)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackton1 committed Feb 16, 2023
1 parent bda7fb2 commit ca6650c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions diff-sha.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

set -euo pipefail
set -euxo pipefail

INITIAL_COMMIT="false"
GITHUB_OUTPUT=${GITHUB_OUTPUT:-""}
Expand Down Expand Up @@ -57,7 +57,7 @@ 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 +refs/heads/"$CURRENT_BRANCH":refs/remotes/origin/"$CURRENT_BRANCH" 1>/dev/null
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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..."
Expand Down

0 comments on commit ca6650c

Please sign in to comment.