MCPcopy Create free account
hub / github.com/ejoffe/spr / CreatePullRequest

Method CreatePullRequest

github/githubclient/client.go:412–459  ·  view source on GitHub ↗
(ctx context.Context, gitcmd git.GitInterface,
	info *github.GitHubInfo, commit git.Commit, prevCommit *git.Commit)

Source from the content-addressed store, hash-verified

410}
411
412func (c *client) CreatePullRequest(ctx context.Context, gitcmd git.GitInterface,
413 info *github.GitHubInfo, commit git.Commit, prevCommit *git.Commit) *github.PullRequest {
414
415 baseRefName := c.config.Repo.GitHubBranch
416 if prevCommit != nil {
417 baseRefName = git.BranchNameFromCommit(c.config, *prevCommit)
418 }
419 headRefName := git.BranchNameFromCommit(c.config, commit)
420
421 log.Debug().Interface("Commit", commit).
422 Str("FromBranch", headRefName).Str("ToBranch", baseRefName).
423 Msg("CreatePullRequest")
424
425 templatizer := config_fetcher.PRTemplatizer(c.config, gitcmd)
426
427 body := templatizer.Body(info, commit, nil)
428 resp, err := c.api.CreatePullRequest(ctx, genclient.CreatePullRequestInput{
429 RepositoryId: info.RepositoryID,
430 BaseRefName: baseRefName,
431 HeadRefName: headRefName,
432 Title: templatizer.Title(info, commit),
433 Body: &body,
434 Draft: &c.config.User.CreateDraftPRs,
435 })
436 check(err)
437
438 pr := &github.PullRequest{
439 ID: resp.CreatePullRequest.PullRequest.Id,
440 Number: resp.CreatePullRequest.PullRequest.Number,
441 FromBranch: headRefName,
442 ToBranch: baseRefName,
443 Commit: commit,
444 Title: commit.Subject,
445 Body: resp.CreatePullRequest.PullRequest.Body,
446 MergeStatus: github.PullRequestMergeStatus{
447 ChecksPass: github.CheckStatusUnknown,
448 ReviewApproved: false,
449 NoConflicts: false,
450 Stacked: false,
451 },
452 }
453
454 if c.config.User.LogGitHubCalls {
455 fmt.Printf("> github create %d : %s\n", pr.Number, pr.Title)
456 }
457
458 return pr
459}
460
461func (c *client) UpdatePullRequest(ctx context.Context, gitcmd git.GitInterface,
462 info *github.GitHubInfo, pullRequests []*github.PullRequest, pr *github.PullRequest,

Callers

nothing calls this directly

Calls 6

BranchNameFromCommitFunction · 0.92
PRTemplatizerFunction · 0.92
checkFunction · 0.70
BodyMethod · 0.65
CreatePullRequestMethod · 0.65
TitleMethod · 0.65

Tested by

no test coverage detected