Merge pull request #862 from tj-actions/feat/add-support-for-pulling-more-history
feat: add support for pulling more history
This commit is contained in:
commit
a7b70fa84d
@ -83,12 +83,11 @@ inputs:
|
|||||||
fetch_depth:
|
fetch_depth:
|
||||||
description: "Initial depth of the branch history fetched. **NOTE**: This can be adjusted to resolve errors with insufficient history."
|
description: "Initial depth of the branch history fetched. **NOTE**: This can be adjusted to resolve errors with insufficient history."
|
||||||
required: false
|
required: false
|
||||||
default: "40"
|
default: "50"
|
||||||
max_fetch_depth:
|
max_fetch_depth:
|
||||||
description: "Maximum depth of the branch history fetched. **NOTE**: This can be adjusted to resolve errors with insufficient history."
|
description: "Maximum depth of the branch history fetched. **NOTE**: This can be adjusted to resolve errors with insufficient history."
|
||||||
required: false
|
required: false
|
||||||
default: "5000"
|
default: "6000"
|
||||||
deprecationMessage: "This input is deprecated and will be removed in a future release."
|
|
||||||
since_last_remote_commit:
|
since_last_remote_commit:
|
||||||
description: "Use the last commit on the remote branch as the `base_sha`. Defaults to the last non merge commit on the target branch for pull request events and the previous remote commit of the current branch for push events."
|
description: "Use the last commit on the remote branch as the `base_sha`. Defaults to the last non merge commit on the target branch for pull request events and the previous remote commit of the current branch for push events."
|
||||||
required: true
|
required: true
|
||||||
|
26
diff-sha.sh
26
diff-sha.sh
@ -239,6 +239,32 @@ else
|
|||||||
else
|
else
|
||||||
PREVIOUS_SHA=$INPUT_BASE_SHA && exit_status=$? || exit_status=$?
|
PREVIOUS_SHA=$INPUT_BASE_SHA && exit_status=$? || exit_status=$?
|
||||||
fi
|
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 $TARGET_BRANCH $CURRENT_SHA 1>/dev/null 2>&1
|
||||||
|
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::Target branch: $TARGET_BRANCH"
|
||||||
echo "::debug::Current branch: $CURRENT_BRANCH"
|
echo "::debug::Current branch: $CURRENT_BRANCH"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user