( owner: string, repo: string, from: string, to: string, )
| 16 | } |
| 17 | |
| 18 | export async function fetchComparisonDiff( |
| 19 | owner: string, |
| 20 | repo: string, |
| 21 | from: string, |
| 22 | to: string, |
| 23 | ) { |
| 24 | const client = getRequestClient(); |
| 25 | |
| 26 | const response = await client( |
| 27 | "GET /repos/{owner}/{repo}/compare/{base}...{head}", |
| 28 | { |
| 29 | owner, |
| 30 | repo, |
| 31 | base: from, |
| 32 | head: to, |
| 33 | headers: { |
| 34 | accept: DIFF_ACCEPT_HEADER, |
| 35 | }, |
| 36 | }, |
| 37 | ); |
| 38 | |
| 39 | const diff = String(response.data); |
| 40 | |
| 41 | if (diff.trim().length === 0) |
| 42 | throw new Error( |
| 43 | `GitHub comparison diff for ${owner}/${repo} between ${from} and ${to} was empty.`, |
| 44 | ); |
| 45 | |
| 46 | return diff; |
| 47 | } |
| 48 | |
| 49 | export interface CommitDiff { |
| 50 | sha: string; |
no test coverage detected