MCPcopy Index your code
hub / github.com/github/docs / getContents

Function getContents

script/helpers/git-utils.js:84–104  ·  view source on GitHub ↗
(owner, repo, ref, path)

Source from the content-addressed store, hash-verified

82
83// https://docs.github.com/rest/reference/repos#get-repository-content
84export 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
107export async function listPulls(owner, repo) {

Callers 3

mainFunction · 0.90
mainFunction · 0.90
getRemoteRawContentFunction · 0.90

Calls 1

getContentsForBlobFunction · 0.85

Tested by

no test coverage detected