Fix failing of workflow if a PR or the base branch has more than 10 commits. (#6117)

I tried several ways to fix this issue more elegantly.
But I either was too stupid, too tired to do it right, or it got too complex.
The script fails because the PR "base" branch and the PR HEAD
have no merge-base commit in the shallow clone Github does.

If a PR has more than 10 commits, the workflow fails because
the fetching didn't get enough commits to reach the merge-base.

Anyways, this is the simple solution.
Fetch 200 commits at once and done.
The workflow will fail if a PR has more than 200 commits
or the base branch has 200+ commits since creation of the
PR. But this rare and almost always requires a rebase
anyways. So this is the simplest fix.
This commit is contained in:
Rot127 2026-03-29 01:49:03 +00:00 committed by GitHub
parent 37d35d3d69
commit c6d566a44a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -65,14 +65,9 @@ jobs:
- id: get_shas
run: |
git fetch --no-tags --prune --no-recurse-submodules --depth=$((${{ github.event.pull_request.commits }} + 1)) origin ${{ github.event.pull_request.head.sha }}
git fetch --no-tags --prune --no-recurse-submodules --depth=10 origin ${{ github.event.pull_request.base.sha }}
git fetch --no-tags --prune --no-recurse-submodules --depth=200 origin ${{ github.event.pull_request.base.sha }}
git checkout --progress --force ${{ github.event.pull_request.head.sha }}
while [[ -n $(git rev-list shallow ^${{ github.event.pull_request.base.sha }}) ]]
do
git fetch --no-tags --prune --no-recurse-submodules --deepen=10 origin ${{ github.event.pull_request.base.sha }}
done
BASE_SHA=$(git rev-list ${{ github.event.pull_request.head.sha }} ^${{ github.event.pull_request.base.sha }} | tail --lines 1 | xargs -I {} git rev-parse {}~1)
HEAD_SHA=${{ github.event.pull_request.head.sha }}
COMMIT_MSGS=$(git log --pretty=%B "$BASE_SHA".."$HEAD_SHA")