Skip to content

Commit

Open a pull request as a draft: it can't merge, and agents' review routines wait, until it is marked ready

syntaqxcommitted Parentbac01c0Browse files
5 files+29−20/5 viewed
+8−0
184184 move a pull request between these states. An
185185 [archived](/guides/managing-repositories/) repository refuses all of them.
186186
187+### Open a draft
188+
189+When you open a pull request from a branch, choose **Open as draft** to
190+say it isn't ready yet. Push to the branch as often as you like; select
191+**Mark ready for review** when it is. Routines that review pull requests
192+(an agent's routine that runs when a pull request is ready for review) run
193+then, not before. Through the API, send `"draft": true` when you open it.
194+
187195 ### Convert to a draft
188196
189197 To take a pull request that is ready for review back to a draft, select
+10−1
6969 agent: user.username,
7070 runtime: "external",
7171 base: String(form.get("base") ?? "") || undefined,
72+ draft: form.get("intent") === "draft",
7273 },
7374 );
7475 if (!result.ok) return { error: result.error.message };
140141 <Input name="issue" type="number" min={1} defaultValue={issue} placeholder="12" />
141142 </Field>
142143 <ErrorText>{actionData?.error}</ErrorText>
143− <SubmitButton pending="Opening…">Open pull request</SubmitButton>
144+ <div className="flex flex-wrap items-center gap-2">
145+ <SubmitButton name="intent" value="open" match={{ intent: "open" }} pending="Opening…">
146+ Open pull request
147+ </SubmitButton>
148+ <SubmitButton name="intent" value="draft" match={{ intent: "draft" }} variant="quiet" pending="Opening…">
149+ Open as draft
150+ </SubmitButton>
151+ <span className="text-xs text-faint">A draft can't merge, and agents' review routines wait, until you mark it ready.</span>
152+ </div>
144153 </Form>
145154 );
146155 }
+4−0
17771777 /// The branch to merge into: the default branch when absent.
17781778 #[serde(default)]
17791779 pub base: Option<String>,
1780+ /// Opened from a branch as a draft, still being worked on: it can't
1781+ /// merge, and agents' review routines wait, until it is marked ready.
1782+ #[serde(default)]
1783+ pub draft: bool,
17801784 }
17811785
17821786 /// `ready_pull`, `close_pull`, `reopen_pull`, `convert_pull_to_draft` and
+5−0
823823 runtime: Runtime;
824824 /** The branch to merge into: the default branch when left out. */
825825 base?: string;
826+ /**
827+ * Opened from a branch as a draft, still being worked on: it can't merge,
828+ * and agents' review routines wait, until it is marked ready.
829+ */
830+ draft?: boolean;
826831 };
827832
828833 /** One repository's pull requests from `pullsForRepos`, newest first. */
+2−1
13091309 };
13101310 // A branch already holds the work, so its pull request is ready for
13111311 // review from the start; one with a fork starts as a draft.
1312− let status = if branch.is_some() { "open" } else { "draft" };
1312+ // Asked for as a draft, it waits until it is marked ready.
1313+ let status = if branch.is_some() && !a.draft { "open" } else { "draft" };
13131314 let body = Some(a.body.trim().to_owned()).filter(|body| !body.is_empty());
13141315
13151316 let number = self.next_number(&repo.id).await?;