3
0
Fork 0
mirror of https://github.com/tj-actions/changed-files synced 2025-01-29 13:34:51 +00:00

fix: bug with fetching history (#989)

This commit is contained in:
Tonye Jack 2023-02-16 06:15:57 -07:00 committed by GitHub
parent bda7fb2353
commit ca6650c514
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,6 @@
#!/usr/bin/env bash
set -euo pipefail
set -euxo pipefail
INITIAL_COMMIT="false"
GITHUB_OUTPUT=${GITHUB_OUTPUT:-""}
@ -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
@ -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
@ -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..."