fix(forgejo): auto-merge rebases head branch on 'behind base' before retry #44
No reviewers
Labels
No labels
adr
agent:blocked-ci
agent:blocked-human
agent:blocked-resolver
agent:done
agent:in-progress
agent:no-touch
agent:pinged
agent:pr-open
agent:queued
agent:wip
area:board
area:funding
area:infra
area:phy
area:poplink
area:rtl
area:software
area:supply-chain
area:verification
ci-failed
ci-timeout
docs
do-not-merge
human-approved
needs-human-approval
needs-rebase
needs-triage
phase:1
ready-for-review
review:findings
review:pass
risk:tripwire
swarm:quarantined
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Fluid/fluidpop-v1!44
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/auto-merge-rebase-behind-base"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
When
POST /pulls/{n}/mergereturned HTTP 405 "head branch is behind the base branch" (the common case after a PR earlier in a cascade lands),auto-merge.shexited 5 and thepr-approverre-kicked it every 60s — flooding Telegram with hundreds of notifications and never making progress until a human rebased manually.This adds an inline one-shot rebase retry:
behind the base branchin the response body.origin/<base>, force-push with--force-with-lease.MAX_REBASE_RETRIES(default 1) — prevents an infinite cascade if base keeps moving.Refactor splits the existing body into
wait_for_ci,attempt_merge, andrebase_and_pushhelpers so the retry path is a singlewhile :loop.Test plan
bash -n infra/forgejo/auto-merge.sh(passes locally)bash infra/forgejo/auto-merge.sh <pr>on a "behind base" PR and confirm: clone → rebase → push → re-poll CI → approve → merge cycle completes cleanlyNotes
infra/forgejo/**is off-limits per ADR-017 — this PR must be reviewed/merged by Marcos, not by the swarm.fluidpop-pr-approver.servicecan be re-enabled.When `POST /pulls/{n}/merge` returns HTTP 405 "head branch is behind the base branch" (e.g., after a previous PR in the cascade lands), the old script exited 5 and the pr-approver kept calling it in a 60s loop, flooding Telegram with notifications. The merge would never succeed without a manual rebase + force-push. This adds a one-shot rebase retry inline: - Detect 405 with "behind the base branch" in the response body. - Clone the repo into a temp dir, fetch the latest base, rebase the head branch on `origin/<base>`, force-push with `--force-with-lease`. - If rebase produces conflicts, abort, exit 5 — a real human-triage blocker. We do not auto-resolve content conflicts. - After a clean force-push the head SHA changes, so re-run the poll-CI → approve → merge cycle on the new SHA. Retries are capped at MAX_REBASE_RETRIES (default 1) to prevent infinite loops if base keeps moving. Refactors the body into three helpers (rebase_and_push, wait_for_ci, attempt_merge) so the retry loop is a clean `while :`. The git identity used for the rebase commits is the swarm identity (FluidPop Swarm <swarm@pop.coop>); rebases of clean fast-forwardable work preserve the original commit metadata.CI green (head
a74364851e), auto-approving