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

Function SearchRepoAssignableActors

api/queries_repo.go:1355–1413  ·  view source on GitHub ↗

SearchRepoAssignableActors searches assignable actors for a repository with an optional query string. Unlike RepoAssignableActors which fetches all actors with pagination, this returns up to 10 results matching the query, suitable for search-based selection.

(client *Client, repo ghrepo.Interface, query string)

Source from the content-addressed store, hash-verified

1353// query string. Unlike RepoAssignableActors which fetches all actors with pagination, this
1354// returns up to 10 results matching the query, suitable for search-based selection.
1355func SearchRepoAssignableActors(client *Client, repo ghrepo.Interface, query string) ([]AssignableActor, int, error) {
1356 type responseData struct {
1357 Repository struct {
1358 AssignableUsers struct {
1359 TotalCount int
1360 }
1361 SuggestedActors struct {
1362 Nodes []struct {
1363 User struct {
1364 ID string
1365 Login string
1366 Name string
1367 TypeName string `graphql:"__typename"`
1368 } `graphql:"... on User"`
1369 Bot struct {
1370 ID string
1371 Login string
1372 TypeName string `graphql:"__typename"`
1373 } `graphql:"... on Bot"`
1374 }
1375 } `graphql:"suggestedActors(first: 10, query: $query, capabilities: CAN_BE_ASSIGNED)"`
1376 } `graphql:"repository(owner: $owner, name: $name)"`
1377 }
1378
1379 var q *githubv4.String
1380 if query != "" {
1381 v := githubv4.String(query)
1382 q = &v
1383 }
1384
1385 variables := map[string]any{
1386 "owner": githubv4.String(repo.RepoOwner()),
1387 "name": githubv4.String(repo.RepoName()),
1388 "query": q,
1389 }
1390
1391 var result responseData
1392 if err := client.Query(repo.RepoHost(), "SearchRepoAssignableActors", &result, variables); err != nil {
1393 return nil, 0, err
1394 }
1395
1396 var actors []AssignableActor
1397 for _, node := range result.Repository.SuggestedActors.Nodes {
1398 if node.User.TypeName == "User" {
1399 actors = append(actors, AssignableUser{
1400 id: node.User.ID,
1401 login: node.User.Login,
1402 name: node.User.Name,
1403 })
1404 } else if node.Bot.TypeName == "Bot" {
1405 actors = append(actors, AssignableBot{
1406 id: node.Bot.ID,
1407 login: node.Bot.Login,
1408 })
1409 }
1410 }
1411
1412 return actors, result.Repository.AssignableUsers.TotalCount, nil

Callers 1

RepoAssigneeSearchFuncFunction · 0.92

Calls 5

StringMethod · 0.65
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
QueryMethod · 0.65
RepoHostMethod · 0.65

Tested by

no test coverage detected