Skip to content

Commit

Permalink
Update diff-sha.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
jackton1 authored Dec 10, 2022
1 parent a4f296d commit a84c8f5
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions diff-sha.sh
Original file line number Diff line number Diff line change
Expand Up @@ -220,21 +220,23 @@ else
depth=$INPUT_FETCH_DEPTH
max_depth=$INPUT_MAX_FETCH_DEPTH

while ! git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA$DIFF$CURRENT_SHA" 1>/dev/null 2>&1; do
for ((i=0; i<max_depth; i+=depth)); do
echo "Fetching $depth commits..."

# shellcheck disable=SC2086
git fetch $EXTRA_ARGS -u --progress --deepen="$depth" origin +"$GITHUB_REF":refs/remotes/origin/"$CURRENT_BRANCH"

PREVIOUS_SHA=$(git merge-base "$TARGET_BRANCH" "$CURRENT_SHA" 2>&1) && exit_status=$? || exit_status=$?

if [[ $depth -gt $max_depth ]]; then
echo "::error::Unable to locate a common ancestor between $TARGET_BRANCH and $CURRENT_SHA"
exit 1
if git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA$DIFF$CURRENT_SHA" 1>/dev/null 2>&1; then
break
fi

depth=$((depth + 300))
done

if ((i >= max_depth)); then
echo "::error::Unable to locate a common ancestor between $TARGET_BRANCH and $CURRENT_SHA"
exit 1
fi
else
echo "::debug::Not a shallow clone, skipping merge-base check."
fi
Expand Down

0 comments on commit a84c8f5

Please sign in to comment.