fix: auto-resolve merge failures instead of asking for manual merge (#253) #256

Merged
guettlibot merged 1 commits from issue-253-fix into main 2026-05-25 17:38:08 +00:00
guettlibot commented 2026-05-25 17:33:24 +00:00 (Migrated from codeberg.org)

Summary

When fgj pr merge exits 0 but the PR is still open, the loop now auto-resolves instead of immediately setting State/Question:

  • Merge conflicts (mergeable == false): spawns a rebase agent to rebase the branch onto main and push, writes pending-ci state so the next loop iteration waits for CI and retries the merge.
  • No conflicts (mergeable == true or null): retries _merge_pr up to 2 more times with a 5 s pause; closes the issue if any retry succeeds.
  • Fallback: if all retries are exhausted, falls back to the existing behaviour (State/Question + "Please merge manually" comment).

Both the main pending-issue path (section 2b) and the catch-up path use the shared _handle_pr_still_open_after_merge() helper.

Tests added

  • test_merge_fails_open_with_conflicts_spawns_rebase_agentmergeable=false → agent spawned, state written as pending-ci
  • test_merge_fails_open_no_conflicts_retries_and_succeedsmergeable=true, second attempt succeeds → issue closed
  • test_merge_fails_open_no_conflicts_all_retries_exhausted → falls through to State/Question
## Summary When `fgj pr merge` exits 0 but the PR is still open, the loop now auto-resolves instead of immediately setting State/Question: - **Merge conflicts** (`mergeable == false`): spawns a rebase agent to rebase the branch onto main and push, writes `pending-ci` state so the next loop iteration waits for CI and retries the merge. - **No conflicts** (`mergeable == true` or `null`): retries `_merge_pr` up to 2 more times with a 5 s pause; closes the issue if any retry succeeds. - **Fallback**: if all retries are exhausted, falls back to the existing behaviour (State/Question + "Please merge manually" comment). Both the main pending-issue path (section 2b) and the catch-up path use the shared `_handle_pr_still_open_after_merge()` helper. ## Tests added - `test_merge_fails_open_with_conflicts_spawns_rebase_agent` — `mergeable=false` → agent spawned, state written as `pending-ci` - `test_merge_fails_open_no_conflicts_retries_and_succeeds` — `mergeable=true`, second attempt succeeds → issue closed - `test_merge_fails_open_no_conflicts_all_retries_exhausted` → falls through to State/Question
Sign in to join this conversation.