mirror of
https://github.com/tj-actions/changed-files
synced 2025-01-17 19:17:45 +00:00
fix: finding merge-base
This commit is contained in:
parent
d362fea453
commit
4f5723a9fe
1 changed files with 21 additions and 21 deletions
42
diff-sha.sh
42
diff-sha.sh
|
@ -182,27 +182,6 @@ else
|
||||||
echo "::debug::Current SHA: $CURRENT_SHA"
|
echo "::debug::Current SHA: $CURRENT_SHA"
|
||||||
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
|
|
||||||
|
|
||||||
while [ -z "$( git merge-base --fork-point "$TARGET_BRANCH" HEAD )" ] || [ -z "$(git merge-base "$TARGET_BRANCH" HEAD)" ]; do
|
|
||||||
depth=$((depth + 300))
|
|
||||||
|
|
||||||
# shellcheck disable=SC2086
|
|
||||||
git fetch $EXTRA_ARGS --deepen="$depth" origin "$TARGET_BRANCH" HEAD;
|
|
||||||
|
|
||||||
if [[ $depth -gt $max_depth ]]; then
|
|
||||||
echo "::error::Unable to locate a common ancestor between $TARGET_BRANCH and HEAD"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
else
|
|
||||||
echo "::debug::Not a shallow clone, skipping merge-base check."
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -z $INPUT_BASE_SHA ]]; then
|
if [[ -z $INPUT_BASE_SHA ]]; then
|
||||||
if [[ "$INPUT_SINCE_LAST_REMOTE_COMMIT" == "true" ]]; then
|
if [[ "$INPUT_SINCE_LAST_REMOTE_COMMIT" == "true" ]]; then
|
||||||
PREVIOUS_SHA=$GITHUB_EVENT_BEFORE
|
PREVIOUS_SHA=$GITHUB_EVENT_BEFORE
|
||||||
|
@ -230,6 +209,27 @@ else
|
||||||
echo "::debug::Target branch: $TARGET_BRANCH"
|
echo "::debug::Target branch: $TARGET_BRANCH"
|
||||||
echo "::debug::Current branch: $CURRENT_BRANCH"
|
echo "::debug::Current branch: $CURRENT_BRANCH"
|
||||||
|
|
||||||
|
if [[ "$INPUT_SINCE_LAST_REMOTE_COMMIT" == "false" ]]; then
|
||||||
|
if [[ -f .git/shallow ]]; then
|
||||||
|
depth=$INPUT_FETCH_DEPTH
|
||||||
|
max_depth=$INPUT_MAX_FETCH_DEPTH
|
||||||
|
|
||||||
|
while [ -z "$( git merge-base --fork-point "$TARGET_BRANCH" "$CURRENT_SHA" )" ] || [ -z "$(git merge-base "$TARGET_BRANCH" "$CURRENT_SHA")" ] || [ -z "$(git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA"..."$CURRENT_SHA" | head -1)" ]; do
|
||||||
|
depth=$((depth + 300))
|
||||||
|
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
git fetch $EXTRA_ARGS --deepen="$depth" origin "$TARGET_BRANCH" HEAD;
|
||||||
|
|
||||||
|
if [[ $depth -gt $max_depth ]]; then
|
||||||
|
echo "::error::Unable to locate a common ancestor between $TARGET_BRANCH and HEAD"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
else
|
||||||
|
echo "::debug::Not a shallow clone, skipping merge-base check."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
echo "::debug::Verifying the previous commit SHA: $PREVIOUS_SHA"
|
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=$?
|
git rev-parse --quiet --verify "$PREVIOUS_SHA^{commit}" 1>/dev/null 2>&1 && exit_status=$? || exit_status=$?
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue