diff --git a/dist/index.js b/dist/index.js index b63b5fd..893aae4 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1362,9 +1362,16 @@ class GitHubHelper { type: 'blob' }; }))); + const chunkSize = 100; + const chunkedTreeObjects = Array.from({ length: Math.ceil(treeObjects.length / chunkSize) }, (_, i) => treeObjects.slice(i * chunkSize, i * chunkSize + chunkSize)); core.info(`Creating tree for local commit ${commit.sha}`); - const { data: tree } = yield this.octokit.rest.git.createTree(Object.assign(Object.assign({}, repository), { base_tree: parentCommit.tree, tree: treeObjects })); - treeSha = tree.sha; + for (let i = 0; i < chunkedTreeObjects.length; i++) { + const { data: tree } = yield this.octokit.rest.git.createTree(Object.assign(Object.assign({}, repository), { base_tree: treeSha, tree: chunkedTreeObjects[i] })); + treeSha = tree.sha; + if (chunkedTreeObjects.length > 1) { + core.info(`Created tree ${treeSha} of multipart tree (${i + 1} of ${chunkedTreeObjects.length})`); + } + } core.info(`Created tree ${treeSha} for local commit ${commit.sha}`); } const { data: remoteCommit } = yield this.octokit.rest.git.createCommit(Object.assign(Object.assign({}, repository), { parents: [parentCommit.sha], tree: treeSha, message: `${commit.subject}\n\n${commit.body}` })); diff --git a/src/github-helper.ts b/src/github-helper.ts index 08aede0..ff549db 100644 --- a/src/github-helper.ts +++ b/src/github-helper.ts @@ -283,13 +283,27 @@ export class GitHubHelper { } }) ) + + const chunkSize = 100 + const chunkedTreeObjects: TreeObject[][] = Array.from( + {length: Math.ceil(treeObjects.length / chunkSize)}, + (_, i) => treeObjects.slice(i * chunkSize, i * chunkSize + chunkSize) + ) + core.info(`Creating tree for local commit ${commit.sha}`) - const {data: tree} = await this.octokit.rest.git.createTree({ - ...repository, - base_tree: parentCommit.tree, - tree: treeObjects - }) - treeSha = tree.sha + for (let i = 0; i < chunkedTreeObjects.length; i++) { + const {data: tree} = await this.octokit.rest.git.createTree({ + ...repository, + base_tree: treeSha, + tree: chunkedTreeObjects[i] + }) + treeSha = tree.sha + if (chunkedTreeObjects.length > 1) { + core.info( + `Created tree ${treeSha} of multipart tree (${i + 1} of ${chunkedTreeObjects.length})` + ) + } + } core.info(`Created tree ${treeSha} for local commit ${commit.sha}`) }