MCPcopy
hub / github.com/cli/cli / RepoProjects

Function RepoProjects

api/queries_repo.go:1094–1129  ·  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

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

Callers 1

v1ProjectsFunction · 0.85

Calls 5

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

Tested by

no test coverage detected