CI: full history for the pull-request merge (the depth expression came out shallow), and git's own words when a merge cannot start

This commit is contained in:
The412Banner committed 2026-09-22 21:40:22 -04:00
1 parent e228eca65e
commit 38df1e8141
1 file changed
+15 -1
+15 -1
View File
@@ -59,7 +59,8 @@ jobs:
- uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.sha }}
fetch-depth: ${{ github.event_name == 'pull_request_target' && 0 || 1 }}
# Full history: the merge below needs it (a shallow clone refuses to merge at all).
fetch-depth: 0
# The pull request as it would be once merged onto main is what gets built. When it cannot
# be merged, the conflicting files and the conflicting hunks go into the run summary and the
@@ -83,6 +84,19 @@ jobs:
exit 0
fi
FILES=$(git diff --name-only --diff-filter=U)
if [ -z "$FILES" ]; then
# The merge did not even start (git said why): quote it rather than list nothing.
{
echo "### ❌ Could not merge onto main (\`$BASE\`)"
echo
echo '```'
cat /tmp/merge.out
echo '```'
} > /tmp/pr-merge.md
cat /tmp/pr-merge.md >> "$GITHUB_STEP_SUMMARY"
echo "::error::git could not merge main: $(head -3 /tmp/merge.out | tr '\n' ' ')"
exit 1
fi
{
echo "### ❌ Not mergeable — conflicts with main (\`$BASE\`)"
echo