Stacked pull requests
A stack is a chain of open pull requests in one repository where each one’s base branch is the head branch of the one below it, and the lowest one targets a protected branch such as main:
main <- #41 (head feat/a) <- #42 (base feat/a, head feat/b) <- #43 (base feat/b, head feat/c)fremforge detects a stack from the branches. There is nothing to declare.
- One repository. A pull request from a fork never joins a stack.
- At most 20 layers merge as one unit. A deeper chain is shown, but not merged as a unit.
- A fork in the stack, a branch that two open pull requests build on, is shown and is not merged as a unit until the chain is single again.
- Any author. Layers can come from different people. Every layer keeps its own rules (below).
See a stack
GET /api/v1/repos/{owner}/{repo}/pulls/{index}/stacklists the layers bottom-up, which of them a stack merge of that pull request lands, each layer’s gate, and the lowest layer that blocks the stack.- Explore → Pull requests shows a chip such as stack 2/3 on each layer. Its tooltip shows the chain and the target branch. In the Held view a held stack stays together, bottom-up, and a held layer says that it holds the stack.
/whyand theexplain_pull_requestMCP tool add astackline: which stack the pull request is in, the top to merge, and the layer that blocks it, with its reasons.
Land a stack
Merge the top pull request with stack: true:
curl -X POST "https://frem.sh/api/v1/repos/<owner>/<repo>/pulls/<top>/merge" \
-H "Authorization: token $FORGEJO_TOKEN" \
-H "Content-Type: application/json" \
-d '{"Do": "squash", "stack": true}'Every layer up to the top lands on the target branch in one step: one squash commit per layer (the default, "stack_style": "per-layer"), or one squash commit for the whole stack ("stack_style": "whole"). Either every layer lands or none does.
Add "merge_when_checks_succeed": true to arm auto-merge on the whole stack. It lands once every layer is ready. A push to any layer by someone other than the person who armed it cancels the stack’s auto-merge.
Without stack: true, merging a pull request merges only that pull request, as before.
Every layer keeps its own rules
A stack merge is never a way past a rule. Each layer is judged against the protection of the branch the stack lands on, as if it were merged there alone:
- its required checks must have passed on its exact head commit;
- its approvals count only while the diff they approved is unchanged. A push to a lower layer that changes an upper layer’s diff dismisses that layer’s approvals, unless the diff is byte-identical;
- the person merging needs the right to merge every layer;
- a merge hold or a release-age wait on any layer holds the whole stack.
A target branch that requires signed commits, or that merges through the merge queue, does not take stack merges yet.
When a lower layer lands on its own
If the bottom pull request is merged on its own, the layer above it is moved onto the branch it landed on. Its commits are not touched, so its checks still apply. Its approvals stay only if its diff is byte-identical afterwards: after a squash merge they are dismissed, because its diff now also shows the lower layer’s change. Auto-merge armed on the moved pull request is cancelled, because it was armed for the old base. The pull request is moved only when the person who merged could edit it; otherwise it stays where it is.