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

Method Resolve

pkg/cmd/pr/checkout/checkout.go:436–478  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

434}
435
436func (r *promptingPRResolver) Resolve() (*api.PullRequest, ghrepo.Interface, error) {
437 r.io.StartProgressIndicator()
438 listResult, err := r.prLister.List(shared.ListOptions{
439 BaseRepo: r.baseRepo,
440 State: "open",
441 Fields: []string{
442 "number",
443 "title",
444 "state",
445 "isDraft",
446
447 "headRefName",
448 "headRepository",
449 "headRepositoryOwner",
450 "isCrossRepository",
451 "maintainerCanModify",
452 },
453 LimitResults: 10})
454 r.io.StopProgressIndicator()
455 if err != nil {
456 return nil, nil, err
457 }
458 if len(listResult.PullRequests) == 0 {
459 return nil, nil, shared.ListNoResults(ghrepo.FullName(r.baseRepo), "pull request", false)
460 }
461
462 candidates := []string{}
463 for _, pr := range listResult.PullRequests {
464 candidates = append(candidates, fmt.Sprintf("%d\t%s %s [%s]",
465 pr.Number,
466 shared.PrStateWithDraft(&pr),
467 text.RemoveExcessiveWhitespace(pr.Title),
468 pr.HeadLabel(),
469 ))
470 }
471
472 selected, err := r.prompter.Select("Select a pull request", "", candidates)
473 if err != nil {
474 return nil, nil, err
475 }
476
477 return &listResult.PullRequests[selected], r.baseRepo, nil
478}

Callers 1

TestPromptingPRResolverFunction · 0.95

Calls 9

ListNoResultsFunction · 0.92
FullNameFunction · 0.92
PrStateWithDraftFunction · 0.92
HeadLabelMethod · 0.80
ListMethod · 0.65
StopProgressIndicatorMethod · 0.65
SelectMethod · 0.65

Tested by 1

TestPromptingPRResolverFunction · 0.76