@@ -157,11 +157,25 @@ runs:
157157 # Uses github.token (has contents:read) instead of the App token (used for posting reviews).
158158 # Uses the full PR URL instead of just the number — gh can't resolve a bare number
159159 # from a detached HEAD (refs/pull/N/head).
160- if GH_TOKEN="$READ_TOKEN" gh pr diff "$PR_URL" > pr.diff 2>/dev/null; then
161- echo "✅ Pre-fetched PR diff ($(wc -l < pr.diff | tr -d ' ') lines)"
160+ if GH_TOKEN="$READ_TOKEN" gh pr diff "$PR_URL" > pr.diff 2>pr_diff_stderr.txt; then
161+ echo "✅ Pre-fetched PR diff via gh pr diff ($(wc -l < pr.diff | tr -d ' ') lines)"
162+ rm -f pr_diff_stderr.txt
162163 else
163- echo "::warning::Failed to pre-fetch PR diff — agent will use git diff as fallback"
164- rm -f pr.diff
164+ echo "::warning::gh pr diff failed: $(cat pr_diff_stderr.txt 2>/dev/null)"
165+ rm -f pr.diff pr_diff_stderr.txt
166+
167+ # Fallback: git diff with merge-base (repo is checked out with full history)
168+ MERGE_BASE=$(git merge-base origin/main HEAD 2>/dev/null || git merge-base origin/master HEAD 2>/dev/null || echo "")
169+ if [ -n "$MERGE_BASE" ]; then
170+ if git diff "$MERGE_BASE"...HEAD > pr.diff; then
171+ echo "✅ Pre-fetched PR diff via git diff ($(wc -l < pr.diff | tr -d ' ') lines)"
172+ else
173+ echo "::warning::git diff failed — agent will fetch diff itself"
174+ rm -f pr.diff
175+ fi
176+ else
177+ echo "::warning::Could not determine merge base — agent will fetch diff itself"
178+ fi
165179 fi
166180
167181 - name : Resolve stale review threads
@@ -358,8 +372,9 @@ runs:
358372 uses : actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
359373 with :
360374 path : ${{ github.workspace }}/.cache/pr-review-memory.db
361- key : pr-review-memory-${{ github.repository }}-${{ github.run_id }}
375+ key : pr-review-memory-${{ github.repository }}-${{ github.job }}-${{ github. run_id }}
362376 restore-keys : |
377+ pr-review-memory-${{ github.repository }}-${{ github.job }}-
363378 pr-review-memory-${{ github.repository }}-
364379
365380 # ========================================
@@ -541,7 +556,7 @@ runs:
541556 uses : actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
542557 with :
543558 path : ${{ github.workspace }}/.cache/pr-review-memory.db
544- key : pr-review-memory-${{ github.repository }}-${{ github.run_id }}
559+ key : pr-review-memory-${{ github.repository }}-${{ github.job }}-${{ github. run_id }}
545560
546561 # ========================================
547562 # POST-REVIEW: Clean summary & reactions
0 commit comments