Skip to content

Commit

Permalink
Handle PRs not based off recent main in large files check (#26420)
Browse files Browse the repository at this point in the history
Previously failed due to trying to go all the way back to what Github
calls the "base" SHA, which turns out is what we'll merge on top of
rather than the parent of the first commit in the PR.

Follow up to #26371.

[trivial fix, not reviewed]
  • Loading branch information
riftEmber authored Dec 16, 2024
2 parents d0f5071 + c198a30 commit d707108
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,15 @@ jobs:
baseSHA=${{github.event.pull_request.base.sha}}
headSHA=${{github.event.pull_request.head.sha}}
echo "Base SHA: $baseSHA"
echo "Head SHA: $headSHA"
echo "${{github.event.pull_request.commits}} commits in PR"
# Loop backward through commits added in the PR, starting from the
# latest.
commitIdx=0
for commit in $(git rev-list $baseSHA..$headSHA)
do
if [ "$commit" = "$baseSHA" ]; then
break
fi
echo "Checking commit: $commit"
git checkout -q $commit
Expand All @@ -180,4 +181,11 @@ jobs:
exit 1
fi
done <<< "$newFiles"
# Stop after going through the number of commits this PR has.
commitIdx=$((commitIdx+1))
if [ "$commitIdx" = "${{github.event.pull_request.commits}}" ]; then
echo "Stopping after $commitIdx commits, on commit $commit"
break
fi
done

0 comments on commit d707108

Please sign in to comment.