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

Function RepoProjects

api/queries_repo.go:1102–1137  ·  view source on GitHub ↗

RepoProjects fetches all open projects for a repository.

(client *Client, repo ghrepo.Interface)

Source from the content-addressed store, hash-verified

1100
1101// RepoProjects fetches all open projects for a repository.
1102func RepoProjects(client *Client, repo ghrepo.Interface) ([]RepoProject, error) {
1103 type responseData struct {
1104 Repository struct {
1105 Projects struct {
1106 Nodes []RepoProject
1107 PageInfo struct {
1108 HasNextPage bool
1109 EndCursor string
1110 }
1111 } `graphql:"projects(states: [OPEN], first: 100, orderBy: {field: NAME, direction: ASC}, after: $endCursor)"`
1112 } `graphql:"repository(owner: $owner, name: $name)"`
1113 }
1114
1115 variables := map[string]any{
1116 "owner": githubv4.String(repo.RepoOwner()),
1117 "name": githubv4.String(repo.RepoName()),
1118 "endCursor": (*githubv4.String)(nil),
1119 }
1120
1121 var projects []RepoProject
1122 for {
1123 var query responseData
1124 err := client.Query(repo.RepoHost(), "RepositoryProjectList", &query, variables)
1125 if err != nil {
1126 return nil, err
1127 }
1128
1129 projects = append(projects, query.Repository.Projects.Nodes...)
1130 if !query.Repository.Projects.PageInfo.HasNextPage {
1131 break
1132 }
1133 variables["endCursor"] = githubv4.String(query.Repository.Projects.PageInfo.EndCursor)
1134 }
1135
1136 return projects, nil
1137}
1138
1139// Expected login for Copilot when retrieved as an assignee
1140const CopilotAssigneeLogin = "copilot-swe-agent"

Callers 1

v1ProjectsFunction · 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