Skip to content

Commit

Permalink
Fixed test
Browse files Browse the repository at this point in the history
  • Loading branch information
jackton1 committed Dec 5, 2022
1 parent c09cd87 commit 0d9ec12
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions diff-sha.sh
Expand Up @@ -215,39 +215,39 @@ else
PREVIOUS_SHA=$GITHUB_EVENT_PULL_REQUEST_BASE_SHA && exit_status=$? || exit_status=$?
fi

echo "::debug::Previous SHA: $PREVIOUS_SHA"
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

echo "::debug::Target branch: $TARGET_BRANCH"
echo "::debug::Current branch: $CURRENT_BRANCH"
while ! git merge-base "$PREVIOUS_SHA" "$CURRENT_SHA" 1>/dev/null; do
echo "Fetching $depth commits..."

if [[ "$INPUT_SINCE_LAST_REMOTE_COMMIT" == "false" ]]; then
if [[ -f .git/shallow ]]; then
depth=$INPUT_FETCH_DEPTH
max_depth=$INPUT_MAX_FETCH_DEPTH

while ! git merge-base "$PREVIOUS_SHA" "$CURRENT_SHA" 1>/dev/null; do
echo "Fetching $depth commits..."
# shellcheck disable=SC2086
git fetch $EXTRA_ARGS -u --progress --deepen="$depth" origin +"$GITHUB_REF":refs/remotes/origin/"$CURRENT_BRANCH"

# shellcheck disable=SC2086
git fetch $EXTRA_ARGS -u --progress --deepen="$depth" origin +"$GITHUB_REF":refs/remotes/origin/"$CURRENT_BRANCH"
PREVIOUS_SHA=$(git merge-base origin/"$TARGET_BRANCH" "$CURRENT_SHA" 2>&1)

PREVIOUS_SHA=$(git merge-base origin/"$TARGET_BRANCH" "$CURRENT_SHA" 2>&1)
if [[ $depth -gt $max_depth ]]; then
echo "::error::Unable to locate a common ancestor between $TARGET_BRANCH and $CURRENT_SHA"
exit 1
fi

if [[ $depth -gt $max_depth ]]; then
echo "::error::Unable to locate a common ancestor between $TARGET_BRANCH and $CURRENT_SHA"
exit 1
fi

depth=$((depth + 300))
done
else
echo "::debug::Not a shallow clone, skipping merge-base check."
depth=$((depth + 300))
done
else
echo "::debug::Not a shallow clone, skipping merge-base check."
fi
fi

echo "::debug::Previous SHA: $PREVIOUS_SHA"
else
PREVIOUS_SHA=$INPUT_BASE_SHA && exit_status=$? || exit_status=$?
fi

echo "::debug::Target branch: $TARGET_BRANCH"
echo "::debug::Current branch: $CURRENT_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=$?

Expand Down

0 comments on commit 0d9ec12

Please sign in to comment.