MCPcopy
hub / github.com/peter-evans/create-pull-request / createCommit

Method createCommit

src/github-helper.ts:319–414  ·  view source on GitHub ↗
(
    git: GitCommandManager,
    commit: Commit,
    parentCommit: CommitResponse,
    repoPath: string,
    branchRepository: string
  )

Source from the content-addressed store, hash-verified

317 }
318
319 private async createCommit(
320 git: GitCommandManager,
321 commit: Commit,
322 parentCommit: CommitResponse,
323 repoPath: string,
324 branchRepository: string
325 ): Promise<CommitResponse> {
326 const repository = this.parseRepository(branchRepository)
327 // In the case of an empty commit, the tree references the parent's tree
328 let treeSha = parentCommit.tree
329 if (commit.changes.length > 0) {
330 core.info(`Creating tree objects for local commit ${commit.sha}`)
331 const treeObjects = await Promise.all(
332 commit.changes.map(async ({path, mode, status, dstSha}) => {
333 if (mode === '160000') {
334 // submodule
335 core.info(`Creating tree object for submodule commit at '${path}'`)
336 return <TreeObject>{
337 path,
338 mode,
339 sha: dstSha,
340 type: 'commit'
341 }
342 } else {
343 let sha: string | null = null
344 if (status === 'A' || status === 'M') {
345 try {
346 const {data: blob} = await blobCreationLimit(async () =>
347 this.octokit.rest.git.createBlob({
348 ...repository,
349 content: await git.showFileAtRefBase64(commit.sha, path),
350 encoding: 'base64'
351 })
352 )
353 sha = blob.sha
354 } catch (error) {
355 core.error(
356 `Error creating blob for file '${path}': ${utils.getErrorMessage(error)}`
357 )
358 throw error
359 }
360 }
361 core.info(
362 `Creating tree object for blob at '${path}' with status '${status}'`
363 )
364 return <TreeObject>{
365 path,
366 mode,
367 sha,
368 type: 'blob'
369 }
370 }
371 })
372 )
373
374 const chunkSize = 100
375 const chunkedTreeObjects: TreeObject[][] = Array.from(
376 {length: Math.ceil(treeObjects.length / chunkSize)},

Callers 1

pushSignedCommitsMethod · 0.95

Calls 2

parseRepositoryMethod · 0.95
showFileAtRefBase64Method · 0.80

Tested by

no test coverage detected