Open a pull request as a draft: it can't merge, and agents' review routines wait, until it is marked ready
5 files+29−20/5 viewed
| 184 | 184 | move a pull request between these states. An | |
| 185 | 185 | [archived](/guides/managing-repositories/) repository refuses all of them. | |
| 186 | 186 | ||
| 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 | + | ||
| 187 | 195 | ### Convert to a draft | |
| 188 | 196 | ||
| 189 | 197 | To take a pull request that is ready for review back to a draft, select |
| 69 | 69 | agent: user.username, | |
| 70 | 70 | runtime: "external", | |
| 71 | 71 | base: String(form.get("base") ?? "") || undefined, | |
| 72 | + | draft: form.get("intent") === "draft", | |
| 72 | 73 | }, | |
| 73 | 74 | ); | |
| 74 | 75 | if (!result.ok) return { error: result.error.message }; | |
| ⋯ | |||
| 140 | 141 | <Input name="issue" type="number" min={1} defaultValue={issue} placeholder="12" /> | |
| 141 | 142 | </Field> | |
| 142 | 143 | <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> | |
| 144 | 153 | </Form> | |
| 145 | 154 | ); | |
| 146 | 155 | } | |
| 1777 | 1777 | /// The branch to merge into: the default branch when absent. | |
| 1778 | 1778 | #[serde(default)] | |
| 1779 | 1779 | 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, | |
| 1780 | 1784 | } | |
| 1781 | 1785 | ||
| 1782 | 1786 | /// `ready_pull`, `close_pull`, `reopen_pull`, `convert_pull_to_draft` and |
| 823 | 823 | runtime: Runtime; | |
| 824 | 824 | /** The branch to merge into: the default branch when left out. */ | |
| 825 | 825 | 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; | |
| 826 | 831 | }; | |
| 827 | 832 | ||
| 828 | 833 | /** One repository's pull requests from `pullsForRepos`, newest first. */ |
| 1309 | 1309 | }; | |
| 1310 | 1310 | // A branch already holds the work, so its pull request is ready for | |
| 1311 | 1311 | // 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" }; | |
| 1313 | 1314 | let body = Some(a.body.trim().to_owned()).filter(|body| !body.is_empty()); | |
| 1314 | 1315 | ||
| 1315 | 1316 | let number = self.next_number(&repo.id).await?; |