MCPcopy Index your code
hub / github.com/peter-evans/create-pull-request / createOrUpdateRef

Method createOrUpdateRef

src/github-helper.ts:432–464  ·  view source on GitHub ↗
(
    branchRepository: string,
    branch: string,
    newHead: string
  )

Source from the content-addressed store, hash-verified

430 }
431
432 private async createOrUpdateRef(
433 branchRepository: string,
434 branch: string,
435 newHead: string
436 ) {
437 const repository = this.parseRepository(branchRepository)
438 const branchExists = await this.octokit.rest.repos
439 .getBranch({
440 ...repository,
441 branch: branch
442 })
443 .then(
444 () => true,
445 () => false
446 )
447
448 if (branchExists) {
449 core.info(`Branch ${branch} exists; Updating ref`)
450 await this.octokit.rest.git.updateRef({
451 ...repository,
452 sha: newHead,
453 ref: `heads/${branch}`,
454 force: true
455 })
456 } else {
457 core.info(`Branch ${branch} does not exist; Creating ref`)
458 await this.octokit.rest.git.createRef({
459 ...repository,
460 sha: newHead,
461 ref: `refs/heads/${branch}`
462 })
463 }
464 }
465
466 async convertToDraft(id: string): Promise<void> {
467 core.info(`Converting pull request to draft`)

Callers 1

pushSignedCommitsMethod · 0.95

Calls 1

parseRepositoryMethod · 0.95

Tested by

no test coverage detected