fix(create-pr): retry with live base_commit on force-push scenarios#201
fix(create-pr): retry with live base_commit on force-push scenarios#201jamesadevine wants to merge 1 commit into
Conversation
…193) When the recorded base_commit from Stage 1 becomes unreachable (e.g. the target branch was force-pushed between Stage 1 and Stage 2), the ADO Push API returns HTTP 400. Previously this was a hard failure. Now: if the push fails with 400 and a recorded base_commit was used, fall back to resolving the live target branch HEAD via the ADO refs API and retry the push. This handles the rare but real scenario where the target branch is force-pushed between pipeline stages. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
🔍 Rust PR ReviewSummary: Logic is sound and solves the stated problem, but there are two issues worth addressing. Findings🐛 Bugs / Logic Issues
✅ What Looks Good
|
|
Closing — the base_commit is a merge-base (ancestor of the target branch). Force-pushing the target branch would need to rewrite history past the merge-base AND have ADO GC the old objects between Stage 1 and Stage 2. This is effectively impossible in practice. A FIXME comment is more appropriate than retry logic. |
Closes #193.
Problem
When
self.base_commitis recorded at Stage 1 (merge-base SHA), it's used as the parent commit in the ADO Push API. If the target branch is force-pushed between Stage 1 and Stage 2, that SHA may become unreachable — the push fails with HTTP 400.The existing fallback (resolving live target branch HEAD when
base_commitisNone) doesn't help becausebase_commitisSome.Fix
If the push fails with HTTP 400 and a recorded
base_commitwas used:Testing
All 810 tests pass. This is a runtime-only change (ADO API interaction), so the fix is tested by inspection + the existing integration test coverage for the push flow.