Repository: cli/cli
File: api/queries_repo.go (Go)

Code before:
	Labels         bool
	ProjectsV1     bool
	ProjectsV2     bool
	Milestones     bool
}

// RepoMetadata pre-fetches the metadata for attaching to issues and pull requests
func RepoMetadata(client *Client, repo ghrepo.Interface, input RepoMetadataInput) (*RepoMetadataResult, error) {
	var result RepoMetadataResult
	var g errgroup.Group

	if input.Assignees || input.Reviewers {
		if input.ActorAssignees {
			g.Go(func() error {
				actors, err := RepoAssignableActors(client, repo)
				if err != nil {
					return fmt.Errorf("error fetching assignees: %w", err)
				}
				result.AssignableActors = actors

				// Processing the bots out from the actors
				// because requesting a reviewer leverages
				// result.AssignableUsers.
				// Note: this prevents us from needing to make another
				// request to fetch assignable users when the user has
				// selected to modify both reviewers and assignees.
				var users []AssignableUser
				for _, a := range actors {
					if _, ok := a.(AssignableUser); !ok {
						continue
					}
					users = append(users, a.(AssignableUser))
				}
				result.AssignableUsers = users
				return nil
			})
		} else {
			// Not using Actors, fetch legacy assignable users.
			g.Go(func() error {
				users, err := RepoAssignableUsers(client, repo)
				if err != nil {
					err = fmt.Errorf("error fetching assignees: %w", err)
				}
				result.AssignableUsers = users
				return err
			})
		}
	}

	if input.Reviewers {
		g.Go(func() error {

Review comment (suggestion):
**nit:** it would be nice if this block was maybe a little more condensed 🤏 

```suggestion
				// Filter actors for users to use for pull request reviewers,
				// skip retrieving the same info through result.AssignableUsers.
```

Code after:
	Labels         bool
	ProjectsV1     bool
	ProjectsV2     bool
	Milestones     bool
}

// RepoMetadata pre-fetches the metadata for attaching to issues and pull requests
func RepoMetadata(client *Client, repo ghrepo.Interface, input RepoMetadataInput) (*RepoMetadataResult, error) {
	var result RepoMetadataResult
	var g errgroup.Group

	if input.Assignees || input.Reviewers {
		if input.ActorAssignees {
			g.Go(func() error {
				actors, err := RepoAssignableActors(client, repo)
				if err != nil {
					return fmt.Errorf("error fetching assignable actors: %w", err)
				}
				result.AssignableActors = actors

				// Filter actors for users to use for pull request reviewers,
				// skip retrieving the same info through RepoAssignableUsers().
				var users []AssignableUser
				for _, a := range actors {
					if _, ok := a.(AssignableUser); !ok {
						continue
					}
					users = append(users, a.(AssignableUser))
				}
				result.AssignableUsers = users
				return nil
			})
		} else {
			// Not using Actors, fetch legacy assignable users.
			g.Go(func() error {
				users, err := RepoAssignableUsers(client, repo)
				if err != nil {
					err = fmt.Errorf("error fetching assignable users: %w", err)
				}
				result.AssignableUsers = users
				return err
			})
		}
	}

	if input.Reviewers {
		g.Go(func() error {
			teams, err := OrganizationTeams(client, repo)
			// TODO: better detection of non-org repos
			if err != nil && !strings.Contains(err.Error(), errorResolvingOrganization) {
				err = fmt.Errorf("error fetching organization teams: %w", err)