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:
parent
9b3a93a0c1
commit
9e0389c5ae
1 changed files with 26 additions and 0 deletions
26
diff-sha.sh
26
diff-sha.sh
|
@ -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"
|
||||
|
|
Loading…
Add table
Reference in a new issue