fix: including non branch changes in diff output (#973)
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
This commit is contained in:
parent
2c684aedfa
commit
210cc839c2
3
.github/workflows/test.yml
vendored
3
.github/workflows/test.yml
vendored
@ -210,6 +210,7 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
platform: [ubuntu-latest]
|
platform: [ubuntu-latest]
|
||||||
fetch-depth: [1, 2]
|
fetch-depth: [1, 2]
|
||||||
|
input-fetch_depth: [1, 50]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout to branch
|
- name: Checkout to branch
|
||||||
@ -220,6 +221,8 @@ jobs:
|
|||||||
- name: Run changed-files
|
- name: Run changed-files
|
||||||
id: changed-files
|
id: changed-files
|
||||||
uses: ./
|
uses: ./
|
||||||
|
with:
|
||||||
|
fetch_depth: ${{ matrix.input-fetch_depth }}
|
||||||
|
|
||||||
- name: Show output
|
- name: Show output
|
||||||
run: |
|
run: |
|
||||||
|
22
diff-sha.sh
22
diff-sha.sh
@ -168,8 +168,7 @@ else
|
|||||||
if [[ "$INPUT_SINCE_LAST_REMOTE_COMMIT" != "true" ]]; then
|
if [[ "$INPUT_SINCE_LAST_REMOTE_COMMIT" != "true" ]]; then
|
||||||
echo "::debug::Fetching remote target branch..."
|
echo "::debug::Fetching remote target branch..."
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
git fetch -u --progress $EXTRA_ARGS --depth="$INPUT_FETCH_DEPTH" origin +refs/heads/"$TARGET_BRANCH":refs/remotes/origin/"$TARGET_BRANCH" 1>/dev/null
|
git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" origin "$TARGET_BRANCH:$TARGET_BRANCH" 1>/dev/null
|
||||||
git branch --track "$TARGET_BRANCH" origin/"$TARGET_BRANCH" 1>/dev/null 2>&1 || true
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -209,10 +208,23 @@ else
|
|||||||
PREVIOUS_SHA=$GITHUB_EVENT_PULL_REQUEST_BASE_SHA
|
PREVIOUS_SHA=$GITHUB_EVENT_PULL_REQUEST_BASE_SHA
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
PREVIOUS_SHA=$(git merge-base "$TARGET_BRANCH" "$CURRENT_SHA") && exit_status=$? || exit_status=$?
|
|
||||||
|
|
||||||
if ! git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA$DIFF$CURRENT_SHA" 1>/dev/null 2>&1; then
|
|
||||||
PREVIOUS_SHA=$(git rev-parse origin/"$TARGET_BRANCH") && exit_status=$? || exit_status=$?
|
PREVIOUS_SHA=$(git rev-parse origin/"$TARGET_BRANCH") && exit_status=$? || exit_status=$?
|
||||||
|
|
||||||
|
if [[ -f .git/shallow ]]; then
|
||||||
|
# check if the merge base is in the local history
|
||||||
|
if ! git merge-base "$PREVIOUS_SHA" "$CURRENT_SHA"; then
|
||||||
|
echo "::debug::Merge base is not in the local history, fetching remote target branch..."
|
||||||
|
# Fetch more of the target branch history until the merge base is found
|
||||||
|
for i in {1..10}; do
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" origin "$TARGET_BRANCH:$TARGET_BRANCH" 1>/dev/null
|
||||||
|
if git merge-base "$PREVIOUS_SHA" "$CURRENT_SHA"; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
echo "::debug::Merge base is not in the local history, fetching remote target branch again..."
|
||||||
|
echo "::debug::Attempt $i/10"
|
||||||
|
done
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user