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

Method Resolve

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

Source from the content-addressed store, hash-verified

533}
534
535func (r *promptingPRResolver) Resolve() (*api.PullRequest, ghrepo.Interface, error) {
536 r.io.StartProgressIndicator()
537 listResult, err := r.prLister.List(shared.ListOptions{
538 BaseRepo: r.baseRepo,
539 State: "open",
540 Fields: []string{
541 "number",
542 "title",
543 "state",
544 "isDraft",
545
546 "headRefName",
547 "headRepository",
548 "headRepositoryOwner",
549 "isCrossRepository",
550 "maintainerCanModify",
551 },
552 LimitResults: 10})
553 r.io.StopProgressIndicator()
554 if err != nil {
555 return nil, nil, err
556 }
557 if len(listResult.PullRequests) == 0 {
558 return nil, nil, shared.ListNoResults(ghrepo.FullName(r.baseRepo), "pull request", false)
559 }
560
561 candidates := []string{}
562 for _, pr := range listResult.PullRequests {
563 candidates = append(candidates, fmt.Sprintf("%d\t%s %s [%s]",
564 pr.Number,
565 shared.PrStateWithDraft(&pr),
566 text.RemoveExcessiveWhitespace(pr.Title),
567 pr.HeadLabel(),
568 ))
569 }
570
571 selected, err := r.prompter.Select("Select a pull request", "", candidates)
572 if err != nil {
573 return nil, nil, err
574 }
575
576 return &listResult.PullRequests[selected], r.baseRepo, nil
577}

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