| 1 | import { z } from "zod"; |
| 2 | |
| 3 | export const pullRequestStates = |
| 4 | export const pullRequestFilters = |
| 5 | |
| 6 | type PullRequestSide |
| 7 | |
| 8 | /** `owner:branch` when the side lives in another repository than `other`. A deleted repository has no owner left to name. */ |
| 9 | export function branchLabel(side |
| 10 | if (side.username |
| 11 | return side.username |
| 12 | ? side.ref |
| 13 | : `${side.username |
| 14 | } |
| 15 | |
| 16 | /** `alice:feat/add-rate_limiter` → `Add rate limiter`: the title a request from that branch starts with. */ |
| 17 | export function titleFromBranch(head |
| 18 | const name = |
| 19 | const words = |
| 20 | return words.charAt |
| 21 | } |
| 22 | |
| 23 | export const mergeMethods = |
| 24 | export type MergeMethod |
| 25 | |
| 26 | export type PullRequestState |
| 27 | export type PullRequestFilter |
| 28 | |
| 29 | // git forbids these in a ref name, and `:` separates the owner in `owner:branch` |
| 30 | const REF = / |
| 31 | |
| 32 | export const createPullRequestSchema = |
| 33 | title: z |
| 34 | .string() |
| 35 | .min(1, " |
| 36 | .max(200, " |
| 37 | body: z |
| 38 | .string() |
| 39 | .max(20000, " |
| 40 | .optional(), |
| 41 | base: z |
| 42 | .string() |
| 43 | .min(1, " |
| 44 | .regex(REF, |
| 45 | head: z |
| 46 | .string() |
| 47 | .min(1, " |
| 48 | .regex( |
| 49 | /^[^\s~^:?*[\\ |
| 50 | "Use `branch` or `owner:branch`.", |
| 51 | ), |
| 52 | }); |
| 53 | |
| 54 | export type CreatePullRequestInput |