(opts: GetPullOptions)
| 150 | |
| 151 | /** Fetch pull detail, normalizing the dual field-name shapes. */ |
| 152 | export async function getPull(opts: GetPullOptions): Promise<PullDetail> { |
| 153 | const path = `${pullsPath(opts.owner, opts.db)}/${encodeURIComponent(opts.pullId)}`; |
| 154 | const res = await doltFetch({ |
| 155 | method: 'GET', |
| 156 | path, |
| 157 | auth: opts.auth, |
| 158 | fetch: opts.fetch, |
| 159 | hooks: opts.hooks, |
| 160 | }); |
| 161 | const url = buildDoltUrl(path); |
| 162 | expectOk(res, url, `Get pull ${opts.pullId}`); |
| 163 | const parsed = PullDetailRaw.safeParse(res.json ?? {}); |
| 164 | if (!parsed.success) { |
| 165 | throw new WlDoltHubError( |
| 166 | `Get pull ${opts.pullId} returned an unexpected shape: ${parsed.error.message}`, |
| 167 | res.status, |
| 168 | res.json ?? res.text, |
| 169 | url |
| 170 | ); |
| 171 | } |
| 172 | const raw = parsed.data; |
| 173 | return { |
| 174 | pull_id: raw.pull_id, |
| 175 | title: raw.title, |
| 176 | description: raw.description ?? null, |
| 177 | state: raw.state, |
| 178 | from_branch_name: raw.from_branch_name ?? raw.from_branch ?? null, |
| 179 | to_branch_name: raw.to_branch_name ?? raw.to_branch ?? null, |
| 180 | from_branch_owner_name: raw.from_branch_owner_name ?? raw.from_branch_owner ?? null, |
| 181 | from_branch_repo_name: raw.from_branch_repo_name ?? raw.from_branch_database ?? null, |
| 182 | creator_name: raw.creator_name ?? raw.author ?? null, |
| 183 | created_at: raw.created_at ?? null, |
| 184 | updated_at: raw.updated_at ?? null, |
| 185 | }; |
| 186 | } |
| 187 | |
| 188 | /** |
| 189 | * Open a pull request. `fromOwner` / `fromDb` default to `owner` / |
no test coverage detected