mirror of
https://github.com/tj-actions/changed-files
synced 2025-01-29 03:34:50 +00:00
Merge pull request #722 from tj-actions/fix/bug-with-finding-merge-base
This commit is contained in:
commit
28a044aa26
1 changed files with 9 additions and 7 deletions
16
diff-sha.sh
16
diff-sha.sh
|
@ -68,18 +68,20 @@ else
|
|||
fi
|
||||
|
||||
function deepenShallowCloneToFindCommit() {
|
||||
local ref="$1"
|
||||
local target_branch="$2"
|
||||
local base_ref="$1"
|
||||
local diff="$2"
|
||||
local ref="$3"
|
||||
local target_branch="$4"
|
||||
local depth=20
|
||||
local max_depth=$INPUT_MAX_FETCH_DEPTH
|
||||
|
||||
while ! git rev-parse --quiet --verify "$ref^{commit}" &>/dev/null; do
|
||||
echo "::debug::Unable to find commit '$ref' in shallow clone. Increasing depth to $((depth * 2))..."
|
||||
while ! git diff "$base_ref$diff$ref" &>/dev/null; do
|
||||
echo "::debug::Unable to find merge-base in shallow clone. Increasing depth to $((depth * 2))..."
|
||||
|
||||
depth=$((depth * 2))
|
||||
|
||||
if [[ $depth -gt $max_depth ]]; then
|
||||
echo "::error::Unable to find commit '$ref' in shallow clone. Maximum depth of $max_depth reached."
|
||||
echo "::error::Unable to find merge-base in shallow clone. Please increase 'max_fetch_depth' to at least $((depth + 20))."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -136,7 +138,7 @@ if [[ -z $GITHUB_BASE_REF ]]; then
|
|||
echo "::debug::Current branch $CURRENT_BRANCH..."
|
||||
|
||||
echo "::debug::Fetching previous commit SHA: $PREVIOUS_SHA"
|
||||
deepenShallowCloneToFindCommit "$PREVIOUS_SHA" "$TARGET_BRANCH"
|
||||
deepenShallowCloneToFindCommit "$PREVIOUS_SHA" ".." "$CURRENT_SHA" "$TARGET_BRANCH"
|
||||
|
||||
echo "::debug::Verifying the previous commit SHA: $PREVIOUS_SHA"
|
||||
git rev-parse --quiet --verify "$PREVIOUS_SHA^{commit}" 1>/dev/null 2>&1 && exit_status=$? || exit_status=$?
|
||||
|
@ -162,7 +164,7 @@ else
|
|||
echo "::debug::Current branch: $CURRENT_BRANCH"
|
||||
|
||||
echo "::debug::Fetching previous commit SHA: $PREVIOUS_SHA"
|
||||
deepenShallowCloneToFindCommit "$PREVIOUS_SHA" "$TARGET_BRANCH"
|
||||
deepenShallowCloneToFindCommit "$PREVIOUS_SHA" "..." "$CURRENT_SHA" "$TARGET_BRANCH"
|
||||
|
||||
echo "::debug::Verifying the previous commit SHA: $PREVIOUS_SHA"
|
||||
git rev-parse --quiet --verify "$PREVIOUS_SHA^{commit}" 1>/dev/null 2>&1 && exit_status=$? || exit_status=$?
|
||||
|
|
Loading…
Reference in a new issue