3
0
Fork 0
mirror of https://github.com/tj-actions/changed-files synced 2025-02-19 05:23:48 +00:00

feat: add support for pulling more history

This commit is contained in:
Tonye Jack 2022-12-14 08:04:31 -07:00 committed by GitHub
parent 9b3a93a0c1
commit 9e0389c5ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -239,6 +239,32 @@ else
else
PREVIOUS_SHA=$INPUT_BASE_SHA && exit_status=$? || exit_status=$?
fi
if [[ "$INPUT_SINCE_LAST_REMOTE_COMMIT" == "false" ]]; then
if [[ -f .git/shallow ]]; then
depth=$INPUT_FETCH_DEPTH
max_depth=$INPUT_MAX_FETCH_DEPTH
for ((i=0; i<max_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
echo "Fetching $i commits..."
# shellcheck disable=SC2086
git fetch $EXTRA_ARGS -u --progress --deepen="$i" origin +"$GITHUB_REF":refs/remotes/origin/"$CURRENT_BRANCH"
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"