MCPcopy Create free account
hub / github.com/cli/cli / NewMergeContext

Function NewMergeContext

pkg/cmd/pr/merge/merge.go:568–597  ·  view source on GitHub ↗

Creates a new MergeContext from MergeOptions.

(opts *MergeOptions)

Source from the content-addressed store, hash-verified

566
567// Creates a new MergeContext from MergeOptions.
568func NewMergeContext(opts *MergeOptions) (*mergeContext, error) {
569 findOptions := shared.FindOptions{
570 Selector: opts.SelectorArg,
571 Fields: []string{"id", "number", "state", "title", "lastCommit", "mergeStateStatus", "headRepositoryOwner", "headRefName", "baseRefName", "headRefOid", "isInMergeQueue", "isMergeQueueEnabled"},
572 }
573 pr, baseRepo, err := opts.Finder.Find(findOptions)
574 if err != nil {
575 return nil, err
576 }
577
578 httpClient, err := opts.HttpClient()
579 if err != nil {
580 return nil, err
581 }
582
583 return &mergeContext{
584 opts: opts,
585 pr: pr,
586 cs: opts.IO.ColorScheme(),
587 baseRepo: baseRepo,
588 isTerminal: opts.IO.IsStdoutTTY(),
589 httpClient: httpClient,
590 merged: pr.State == MergeStateStatusMerged,
591 deleteBranch: opts.DeleteBranch,
592 crossRepoPR: pr.HeadRepositoryOwner.Login != baseRepo.RepoOwner(),
593 autoMerge: opts.AutoMergeEnable && !isImmediatelyMergeable(pr.MergeStateStatus),
594 localBranchExists: opts.CanDeleteLocalBranch && opts.GitClient.HasLocalBranch(context.Background(), pr.HeadRefName),
595 mergeQueueRequired: pr.IsMergeQueueEnabled,
596 }, nil
597}
598
599// Run the merge command.
600func mergeRun(opts *MergeOptions) error {

Callers 1

mergeRunFunction · 0.85

Calls 6

isImmediatelyMergeableFunction · 0.85
ColorSchemeMethod · 0.80
IsStdoutTTYMethod · 0.80
FindMethod · 0.65
RepoOwnerMethod · 0.65
HasLocalBranchMethod · 0.65

Tested by

no test coverage detected