(owner, repo, ref, path)
| 82 | |
| 83 | // https://docs.github.com/rest/reference/repos#get-repository-content |
| 84 | export async function getContents(owner, repo, ref, path) { |
| 85 | try { |
| 86 | const { data } = await github.repos.getContent({ |
| 87 | owner, |
| 88 | repo, |
| 89 | ref, |
| 90 | path, |
| 91 | }) |
| 92 | |
| 93 | if (!data.content) { |
| 94 | const blob = await getContentsForBlob(owner, repo, data.sha) |
| 95 | // decode Base64 encoded contents |
| 96 | return Buffer.from(blob, 'base64').toString() |
| 97 | } |
| 98 | // decode Base64 encoded contents |
| 99 | return Buffer.from(data.content, 'base64').toString() |
| 100 | } catch (err) { |
| 101 | console.log(`error getting ${path} from ${owner}/${repo} at ref ${ref}`) |
| 102 | throw err |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | // https://docs.github.com/en/rest/reference/pulls#list-pull-requests |
| 107 | export async function listPulls(owner, repo) { |
no test coverage detected