3
0
Fork 0
mirror of https://github.com/tj-actions/changed-files synced 2024-12-17 13:47:20 +00:00

Update diff-sha.sh

This commit is contained in:
Tonye Jack 2022-11-06 23:28:15 -07:00 committed by GitHub
parent 321490c60a
commit c46761fdcd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,6 +4,11 @@ set -euo pipefail
INITIAL_COMMIT="false"
GITHUB_OUTPUT=${GITHUB_OUTPUT:-""}
EXTRA_ARGS="--no-tags"
if [[ "$GITHUB_REF" == "refs/tags/"* ]]; then
EXTRA_ARGS=""
fi
echo "::group::changed-files-diff-sha"
@ -56,7 +61,8 @@ 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"
# shellcheck disable=SC2086
git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH"
CURRENT_SHA=$INPUT_SHA; exit_status=$?
fi
fi
@ -118,7 +124,8 @@ if [[ -z $GITHUB_BASE_REF ]]; then
fi
fi
else
git fetch --no-tags -u --progress --deepen="$INPUT_FETCH_DEPTH"
# shellcheck disable=SC2086
git fetch $EXTRA_ARGS -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
@ -143,13 +150,15 @@ else
echo "Fetching remote refs..."
if [[ "$INPUT_SINCE_LAST_REMOTE_COMMIT" == "false" ]]; then
git fetch --no-tags --depth="$INPUT_FETCH_DEPTH" origin +refs/heads/"$TARGET_BRANCH":refs/remotes/origin/"$TARGET_BRANCH"
# shellcheck disable=SC2086
git fetch $EXTRA_ARGS --depth="$INPUT_FETCH_DEPTH" origin +refs/heads/"$TARGET_BRANCH":refs/remotes/origin/"$TARGET_BRANCH"
git branch --track "$TARGET_BRANCH" origin/"$TARGET_BRANCH" 2>/dev/null || true
depth=$INPUT_FETCH_DEPTH
while [ -z "$( git merge-base "$TARGET_BRANCH" HEAD )" ]; do
git fetch --no-tags --deepen="$depth" origin "$TARGET_BRANCH" HEAD;
# shellcheck disable=SC2086
git fetch $EXTRA_ARGS --deepen="$depth" origin "$TARGET_BRANCH" HEAD;
depth=$((depth * 10))
max_depth=5000