ci(contributor-check): add base-ref fallback for Gitea checkout robustness #34

Merged
agent-dev-a merged 2 commits from local/fix-contributor-check-robustness into main 2026-05-26 00:07:34 +00:00
2 changed files with 32 additions and 7 deletions
+22 -3
View File
@@ -22,6 +22,10 @@ jobs:
set -euo pipefail
BASE="${{ github.event.pull_request.base.sha }}"
HEAD="${{ github.event.pull_request.head.sha }}"
# Ensure the base ref exists (Gitea checkout may not fetch it).
if ! git cat-file -e "$BASE" 2>/dev/null; then
git fetch --depth=100 origin main || true
fi
changed="$(git diff --name-only "$BASE" "$HEAD")"
printf '%s\n' "$changed"
if printf '%s\n' "$changed" | grep -Eq '(^|/).*\.py$'; then
@@ -37,11 +41,26 @@ jobs:
- name: Check for unmapped contributor emails
if: steps.changes.outputs.run == 'true'
run: |
# Get the merge base between this PR and main
MERGE_BASE=$(git merge-base origin/main HEAD)
set -euo pipefail
BASE="${{ github.event.pull_request.base.sha }}"
HEAD="${{ github.event.pull_request.head.sha }}"
# Ensure the base ref exists (Gitea checkout may not fetch it).
if ! git cat-file -e "$BASE" 2>/dev/null; then
git fetch --depth=100 origin main || true
fi
# If we still can't resolve the base, fall back to merge-base.
if ! git cat-file -e "$BASE" 2>/dev/null; then
BASE=$(git merge-base origin/main HEAD 2>/dev/null || echo "")
if [ -z "$BASE" ]; then
echo "❌ Cannot determine merge base — cannot verify attribution."
exit 1
fi
fi
# Find any new author emails in this PR's commits
NEW_EMAILS=$(git log ${MERGE_BASE}..HEAD --format='%ae' --no-merges | sort -u)
NEW_EMAILS=$(git log "${BASE}..${HEAD}" --format='%ae' --no-merges | sort -u)
if [ -z "$NEW_EMAILS" ]; then
echo "No new commits to check."
+10 -4
View File
@@ -44,8 +44,11 @@ jobs:
git fetch --depth=100 origin main || true
fi
if ! git cat-file -e "$base" 2>/dev/null; then
echo "run=true" >> "$GITHUB_OUTPUT"
exit 0
base=$(git merge-base origin/main HEAD 2>/dev/null || echo "")
if [ -z "$base" ]; then
echo "run=true" >> "$GITHUB_OUTPUT"
exit 0
fi
fi
changed="$(git diff --name-only "$base" "$head")"
printf '%s\n' "$changed"
@@ -134,8 +137,11 @@ jobs:
git fetch --depth=100 origin main || true
fi
if ! git cat-file -e "$base" 2>/dev/null; then
echo "run=true" >> "$GITHUB_OUTPUT"
exit 0
base=$(git merge-base origin/main HEAD 2>/dev/null || echo "")
if [ -z "$base" ]; then
echo "run=true" >> "$GITHUB_OUTPUT"
exit 0
fi
fi
changed="$(git diff --name-only "$base" "$head")"
printf '%s\n' "$changed"