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

Function FetchOptions

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

Source from the content-addressed store, hash-verified

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