import { mergeStack, restackPullRequest } from "~/fns/stacks"; import { useAction } from "~/hooks/use-action"; import { Button } from "~/ui/Button"; import { Callout, ErrorBanner } from "~/ui/Callout"; import { Code } from "~/ui/Code"; import type { usePull } from "~/hooks/use-pull"; import type { MergeMethod } from "~/lib/types"; type PullData = ReturnType; /** * Merge box controls for a pull request stacked on another one: it can't merge into its parent's branch * from here, so it offers restacking onto the parent and merging the whole stack up to this point. */ export function StackMergeControls({ owner, repo, data, method, }: { owner: string; repo: string; data: PullData; method: MergeMethod; }) { const restack = useAction(restackPullRequest); const merge = useAction(mergeStack); const { pull, stackedOn, stack } = data; if (!stackedOn) return null; const below = stack.filter((entry) => !entry.merged && entry.state === "open"); const count = below.findIndex((entry) => entry.current) + 1; const trunk = stack[0]?.baseRef ?? pull.baseRef; return (
Stacked on #{stackedOn.number}. When the pull requests below merge, this one is retargeted to{" "} {trunk} and restacked automatically.
{data.needsRestack && data.canPushHead && ( )} {data.canMerge && !data.autoMerge && ( )}
{data.autoMerge && (

Auto-merge is on: this merges into {trunk} once everything below it has merged and its checks pass.

)}
); }