fix: fetch current PR head for review diffs#722
Merged
Conversation
Prefer a freshly fetched refs/pull/<n>/head over a reachable recorded pr_head= so reviewers never hold a merge over a "missing" fix that already landed on the remote PR. Recorded SHA is offline fallback only; local branch is last resort with a warning. Store the tip under refs/fm-review/ so a later base-branch fetch cannot clobber the compare tip via FETCH_HEAD.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Machinery-over-memory fix for Firstmate review diffs: make bin/fm-review-diff.sh FETCH the actual PR head (refs/pull//head) by DEFAULT whenever task meta records pr=, so reviews always compare the true remote PR tip and never a stale local checkout or a stale recorded pr_head=.
This class of bug has bitten reviewers multiple times (holding a merge over a "missing" fix that had already landed on the PR because the review looked at lagging local objects after no-mistakes fix rounds pushed).
Deliberate design choices:
What Changed
refs/fm-review/pull/<n>/headref before generating review diffs, ensuring the remote tip takes precedence over recorded metadata.pr_headand local-branch fallbacks when the PR head cannot be fetched, while preserving local-branch comparisons for tasks without a PR.Risk Assessment
✅ Low: The change is tightly scoped and implements the required fresh PR-head fetch with the specified isolated ref and fallback order; surrounding call paths and updated regression coverage are consistent.
Testing
The prior baseline was successful; focused regression coverage, a direct end-to-end CLI review transcript, and the complete test suite all passed (
FULL_SUITE_EXIT=0).Evidence: End-to-end PR-head review transcript
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
🔧 **Test** - 1 issue found → auto-fixed ✅
command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"🔧 Fix: Isolate session-start nudge tests from gate state
✅ Re-checked - no issues remain.
command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"Baseline configured suite reported successful before this run.bash tests/fm-review-diff.test.shIsolatedbin/fm-review-diff.sh task-x1scenario with stalepr_head=and newer remoterefs/pull/42/headcommand -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; echo "FULL_SUITE_EXIT=$rc"; exit "$rc"✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.