Skip to content

Commit 0f78fea

Browse files
committed
[fix] issue with fetch-depth being too shallow and use the pull request base/head.
1 parent 6882e45 commit 0f78fea

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

.github/workflows/coverage.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ jobs:
2525
steps:
2626
- name: Checkout Repository
2727
uses: actions/checkout@v4
28+
with:
29+
# Fetch enough history for diff against base branch
30+
fetch-depth: 0
2831

2932
- name: Cache cargo builds
3033
uses: Swatinem/rust-cache@v2
@@ -68,8 +71,10 @@ jobs:
6871
if: github.event_name == 'pull_request'
6972
id: changed
7073
run: |
71-
git fetch origin ${{ github.base_ref }} --depth=1
72-
changed_files=$(git diff --name-only origin/${{ github.base_ref }}...HEAD -- '*.rs' | tr '\n' ' ')
74+
# Use GitHub's provided base/head SHAs for accurate diff
75+
base_sha="${{ github.event.pull_request.base.sha }}"
76+
head_sha="${{ github.event.pull_request.head.sha }}"
77+
changed_files=$(git diff --name-only "$base_sha" "$head_sha" -- '*.rs' | tr '\n' ' ')
7378
echo "files=$changed_files" >> "$GITHUB_OUTPUT"
7479
7580
- name: Generate coverage report data

0 commit comments

Comments
 (0)