Fixing PR testing from other fork branches

This commit is contained in:
DrewThomasson
2025-12-28 15:07:02 -05:00
parent ea4dbea67e
commit 6fc6ae535e
2 changed files with 22 additions and 4 deletions

View File

@@ -35,6 +35,7 @@ jobs:
BASE_REF="${{ github.event.pull_request.base.ref }}"
HEAD_REF="${{ github.event.pull_request.head.ref }}"
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
HEAD_REPO_URL="${{ github.event.pull_request.head.repo.clone_url }}"
TRIGGER_SHA="${{ github.sha }}"
FRESH_CLONE=0
@@ -66,9 +67,17 @@ jobs:
if [ "$IS_PR" = "true" ]; then
echo "==> PR detected: simulating GitHub merge (base: $BASE_REF ← head: $HEAD_REF)"
# Fetch both branches
# Fetch both branches. For the head, we must fetch from the actual source repo (fork)
# because 'origin' might not have the fork's branch.
git fetch origin "$BASE_REF":"origin/$BASE_REF"
git fetch origin "$HEAD_REF":"origin/$HEAD_REF"
if [ -n "$HEAD_REPO_URL" ]; then
echo "==> Fetching head from fork: $HEAD_REPO_URL"
git fetch "$HEAD_REPO_URL" "$HEAD_REF":refs/remotes/origin/$HEAD_REF
else
# Fallback (shouldn't happen for PRs)
git fetch origin "$HEAD_REF":"origin/$HEAD_REF"
fi
# Reset to base branch
git checkout -B "$BASE_REF" "remotes/origin/$BASE_REF"

View File

@@ -95,6 +95,7 @@ jobs:
BASE_REF="${{ github.event.pull_request.base.ref }}"
HEAD_REF="${{ github.event.pull_request.head.ref }}"
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
HEAD_REPO_URL="${{ github.event.pull_request.head.repo.clone_url }}"
TRIGGER_SHA="${{ github.sha }}"
FRESH_CLONE=0
@@ -126,9 +127,17 @@ jobs:
if [ "$IS_PR" = "true" ]; then
echo "==> PR detected: simulating GitHub merge (base: $BASE_REF ← head: $HEAD_REF)"
# Fetch both branches
# Fetch both branches. For the head, we must fetch from the actual source repo (fork)
# because 'origin' might not have the fork's branch.
git fetch origin "$BASE_REF":"origin/$BASE_REF"
git fetch origin "$HEAD_REF":"origin/$HEAD_REF"
if [ -n "$HEAD_REPO_URL" ]; then
echo "==> Fetching head from fork: $HEAD_REPO_URL"
git fetch "$HEAD_REPO_URL" "$HEAD_REF":refs/remotes/origin/$HEAD_REF
else
# Fallback (shouldn't happen for PRs)
git fetch origin "$HEAD_REF":"origin/$HEAD_REF"
fi
# Reset to base branch
git checkout -B "$BASE_REF" "remotes/origin/$BASE_REF"