A pull request whose base moved is refused at the merge; bring the branch up to date before it #221

Closed
opened 2026-10-19 17:44:56 -04:00 by cmoriarty · 1 comment
Owner

Symptom

Run 88 on cmoriarty/aurora-links3 (pull request #10) failed at git.pr.merge: "Forgejo refused to merge cmoriarty/aurora-links3#10 for now: Please try again later". Another run's pull request had merged into main while this one was being built, so the branch no longer merged cleanly (mergeable: false; Forgejo's own POST /pulls/10/update answers 409). Forgejo shows no "Update branch" button either, because it only offers one when the update is clean.

git.pr.merge waits on checks and retries, but it never brings the branch up to date with its base, so a base that moved is a dead end that only a person can clear by hand.

(agent.merge-pr in the spine is only human.merge-pr shown under auto-approve; it merges nothing.)

Wanted

Bring the run's branch up to date with its base before the pull request reaches the merge gate, in the step after git.pr.open:

  • Branch already contains the base: nothing to do.
  • Base moved and the merge is clean: merge it in, push, and record the new head in .osf/pr.json, so git.pr.merge's moved-head belt still holds and checks run once on the final head.
  • Base moved and it conflicts: hand the conflicts to the agent to resolve and re-verify, then push and record the new head.

Also let git.pr.merge catch a base that moved while the gate waited, with Forgejo's update for the clean case.

Run 88 itself needs its conflict resolved by hand.

## Symptom Run 88 on cmoriarty/aurora-links3 (pull request #10) failed at `git.pr.merge`: "Forgejo refused to merge cmoriarty/aurora-links3#10 for now: Please try again later". Another run's pull request had merged into `main` while this one was being built, so the branch no longer merged cleanly (`mergeable: false`; Forgejo's own `POST /pulls/10/update` answers 409). Forgejo shows no "Update branch" button either, because it only offers one when the update is clean. `git.pr.merge` waits on checks and retries, but it never brings the branch up to date with its base, so a base that moved is a dead end that only a person can clear by hand. (`agent.merge-pr` in the spine is only `human.merge-pr` shown under auto-approve; it merges nothing.) ## Wanted Bring the run's branch up to date with its base before the pull request reaches the merge gate, in the step after `git.pr.open`: - Branch already contains the base: nothing to do. - Base moved and the merge is clean: merge it in, push, and record the new head in `.osf/pr.json`, so `git.pr.merge`'s moved-head belt still holds and checks run once on the final head. - Base moved and it conflicts: hand the conflicts to the agent to resolve and re-verify, then push and record the new head. Also let `git.pr.merge` catch a base that moved while the gate waited, with Forgejo's update for the clean case. Run 88 itself needs its conflict resolved by hand.
Author
Owner

Shipped in c9313ba (archived in fb625b1) and live on production.

  • Three steps now sit before git.pr.open in every built-in pipeline: git.sync-base fetches the base from the forge itself (a run's origin is osfd's copy, as old as the clone) and merges it; agent.sync-resolve runs only on a conflict, resolves and stages the files, and never commits; git.commit.sync commits the merge. The pull request opens on a head that has the base, so its checks run once on what will merge.
  • git.pr.merge now fails at once when Forgejo reads the pull request as not mergeable, naming the base and the conflict instead of waiting on "try again later". When it is only behind its base, the step asks Forgejo to update the branch and records the new head in .osf/pr.json.
  • Tests: unit tests over real repositories with a stale local copy, landing tests for the three merge cases, and two simulated runs where the base moves during a run (clean, and conflicting with a resolve). The full lane passed.

Run 88 itself is not repaired by this: its pull request (aurora-links3#10) still has to be merged with main by hand.

Shipped in c9313ba (archived in fb625b1) and live on production. - Three steps now sit before `git.pr.open` in every built-in pipeline: `git.sync-base` fetches the base from the forge itself (a run's `origin` is osfd's copy, as old as the clone) and merges it; `agent.sync-resolve` runs only on a conflict, resolves and stages the files, and never commits; `git.commit.sync` commits the merge. The pull request opens on a head that has the base, so its checks run once on what will merge. - `git.pr.merge` now fails at once when Forgejo reads the pull request as not mergeable, naming the base and the conflict instead of waiting on "try again later". When it is only behind its base, the step asks Forgejo to update the branch and records the new head in `.osf/pr.json`. - Tests: unit tests over real repositories with a stale local copy, landing tests for the three merge cases, and two simulated runs where the base moves during a run (clean, and conflicting with a resolve). The full lane passed. Run 88 itself is not repaired by this: its pull request (aurora-links3#10) still has to be merged with main by hand.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
cmoriarty/braid#221
No description provided.