MCPcopy Index your code
hub / github.com/cli/cli / FetchOptions

Function FetchOptions

pkg/cmd/pr/shared/editable.go:532–641  ·  view source on GitHub ↗
(client *api.Client, repo ghrepo.Interface, editable *Editable, projectV1Support gh.ProjectsV1Support)

Source from the content-addressed store, hash-verified

530}
531
532func FetchOptions(client *api.Client, repo ghrepo.Interface, editable *Editable, projectV1Support gh.ProjectsV1Support) error {
533 // Determine whether to fetch organization teams and reviewers.
534 // Interactive reviewer editing (Edited true, but no Add/Remove slices) still needs
535 // team data for selection UI. For non-interactive flows, we never need to fetch teams
536 // as the REST API accepts team slugs directly.
537 // If we have a search func, we don't need to fetch teams/reviewers since we
538 // assume that will be done dynamically in the prompting flow.
539 teamReviewers := false
540 fetchReviewers := false
541 if editable.Reviewers.Edited {
542 // This is likely an interactive flow since edited is set but no mutations to
543 // Add/Remove slices, so we need to load the teams and reviewers.
544 // However, if we have a search func, skip fetching as it will be done dynamically.
545 if len(editable.Reviewers.Add) == 0 && len(editable.Reviewers.Remove) == 0 && editable.ReviewerSearchFunc == nil {
546 teamReviewers = true
547 fetchReviewers = true
548 }
549 // Note: Non-interactive flows (with Add/Remove) don't need to fetch reviewers/teams
550 // because the APIs in use for both GHES and GitHub.com accept user logins and team slugs directly.
551 }
552
553 fetchAssignees := false
554 if editable.Assignees.Edited {
555 // Similar as above, this is likely an interactive flow if no Add/Remove slices are set.
556 // If we have a search func, we don't need to fetch assignees since we
557 // assume that will be done dynamically in the prompting flow.
558 if len(editable.Assignees.Add) == 0 && len(editable.Assignees.Remove) == 0 && editable.AssigneeSearchFunc == nil {
559 fetchAssignees = true
560 }
561 // For non-interactive Add/Remove operations, we only need to fetch assignees
562 // on GHES where ID resolution is required. On github.com (ApiActorsSupported),
563 // logins are passed directly to the mutation.
564 // TODO ApiActorsSupported
565 if (len(editable.Assignees.Add) > 0 || len(editable.Assignees.Remove) > 0) && !editable.ApiActorsSupported {
566 fetchAssignees = true
567 }
568 }
569
570 input := api.RepoMetadataInput{
571 Reviewers: fetchReviewers,
572 TeamReviewers: teamReviewers,
573 Assignees: fetchAssignees,
574 ApiActorsSupported: editable.ApiActorsSupported,
575 Labels: editable.Labels.Edited,
576 ProjectsV1: editable.Projects.Edited && projectV1Support == gh.ProjectsV1Supported,
577 ProjectsV2: editable.Projects.Edited,
578 Milestones: editable.Milestone.Edited,
579 }
580 metadata, err := api.RepoMetadata(client, repo, input)
581 if err != nil {
582 return err
583 }
584
585 var users []string
586 for _, u := range metadata.AssignableUsers {
587 users = append(users, u.Login())
588 }
589 var actors []string

Callers 2

EditableOptionsFetchMethod · 0.92
EditableOptionsFetchMethod · 0.92

Calls 5

RepoMetadataFunction · 0.92
RepoIssueTypesFunction · 0.92
LoginMethod · 0.65
DisplayNameMethod · 0.65
RepoOwnerMethod · 0.65

Tested by 1

EditableOptionsFetchMethod · 0.74