зеркало из https://github.com/github/docs.git
update graphql scripts for size limit (#32259)
This commit is contained in:
Родитель
7d20d59baa
Коммит
c4b977e9e0
|
@ -70,11 +70,11 @@ export async function getTree(owner, repo, ref) {
|
|||
}
|
||||
|
||||
// https://docs.github.com/rest/reference/git#get-a-blob
|
||||
export async function getContentsForBlob(owner, repo, blob) {
|
||||
export async function getContentsForBlob(owner, repo, sha) {
|
||||
const { data } = await github.git.getBlob({
|
||||
owner,
|
||||
repo,
|
||||
file_sha: blob.sha,
|
||||
file_sha: sha,
|
||||
})
|
||||
// decode blob contents
|
||||
return Buffer.from(data.content, 'base64')
|
||||
|
@ -89,7 +89,13 @@ export async function getContents(owner, repo, ref, path) {
|
|||
ref,
|
||||
path,
|
||||
})
|
||||
// decode contents
|
||||
|
||||
if (!data.content) {
|
||||
const blob = await getContentsForBlob(owner, repo, data.sha)
|
||||
// decode Base64 encoded contents
|
||||
return Buffer.from(blob, 'base64').toString()
|
||||
}
|
||||
// decode Base64 encoded contents
|
||||
return Buffer.from(data.content, 'base64').toString()
|
||||
} catch (err) {
|
||||
console.log(`error getting ${path} from ${owner}/${repo} at ref ${ref}`)
|
||||
|
|
Загрузка…
Ссылка в новой задаче