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

Function RepoLabels

api/queries_repo.go:1422–1457  ·  view source on GitHub ↗

RepoLabels fetches all the labels in a repository

(client *Client, repo ghrepo.Interface)

Source from the content-addressed store, hash-verified

1420
1421// RepoLabels fetches all the labels in a repository
1422func RepoLabels(client *Client, repo ghrepo.Interface) ([]RepoLabel, error) {
1423 type responseData struct {
1424 Repository struct {
1425 Labels struct {
1426 Nodes []RepoLabel
1427 PageInfo struct {
1428 HasNextPage bool
1429 EndCursor string
1430 }
1431 } `graphql:"labels(first: 100, orderBy: {field: NAME, direction: ASC}, after: $endCursor)"`
1432 } `graphql:"repository(owner: $owner, name: $name)"`
1433 }
1434
1435 variables := map[string]any{
1436 "owner": githubv4.String(repo.RepoOwner()),
1437 "name": githubv4.String(repo.RepoName()),
1438 "endCursor": (*githubv4.String)(nil),
1439 }
1440
1441 var labels []RepoLabel
1442 for {
1443 var query responseData
1444 err := client.Query(repo.RepoHost(), "RepositoryLabelList", &query, variables)
1445 if err != nil {
1446 return nil, err
1447 }
1448
1449 labels = append(labels, query.Repository.Labels.Nodes...)
1450 if !query.Repository.Labels.PageInfo.HasNextPage {
1451 break
1452 }
1453 variables["endCursor"] = githubv4.String(query.Repository.Labels.PageInfo.EndCursor)
1454 }
1455
1456 return labels, nil
1457}
1458
1459type RepoMilestone struct {
1460 ID string

Callers 1

RepoMetadataFunction · 0.85

Calls 5

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

Tested by

no test coverage detected