MCPcopy Index your code
hub / github.com/cli/cli / listRepos

Function listRepos

pkg/cmd/repo/list/http.go:32–119  ·  view source on GitHub ↗
(client *http.Client, hostname string, limit int, owner string, filter FilterOptions)

Source from the content-addressed store, hash-verified

30}
31
32func listRepos(client *http.Client, hostname string, limit int, owner string, filter FilterOptions) (*RepositoryList, error) {
33 if filter.Language != "" || filter.Archived || filter.NonArchived || len(filter.Topic) > 0 || filter.Visibility == "internal" {
34 return searchRepos(client, hostname, limit, owner, filter)
35 }
36
37 perPage := limit
38 if perPage > 100 {
39 perPage = 100
40 }
41
42 variables := map[string]interface{}{
43 "perPage": githubv4.Int(perPage),
44 }
45
46 if filter.Visibility != "" {
47 variables["privacy"] = githubv4.RepositoryPrivacy(strings.ToUpper(filter.Visibility))
48 }
49
50 if filter.Fork {
51 variables["fork"] = githubv4.Boolean(true)
52 } else if filter.Source {
53 variables["fork"] = githubv4.Boolean(false)
54 }
55
56 inputs := []string{"$perPage:Int!", "$endCursor:String", "$privacy:RepositoryPrivacy", "$fork:Boolean"}
57 var ownerConnection string
58 if owner == "" {
59 ownerConnection = "repositoryOwner: viewer"
60 } else {
61 ownerConnection = "repositoryOwner(login: $owner)"
62 variables["owner"] = githubv4.String(owner)
63 inputs = append(inputs, "$owner:String!")
64 }
65
66 type result struct {
67 RepositoryOwner struct {
68 Login string
69 Repositories struct {
70 Nodes []api.Repository
71 TotalCount int
72 PageInfo struct {
73 HasNextPage bool
74 EndCursor string
75 }
76 }
77 }
78 }
79
80 query := fmt.Sprintf(`query RepositoryList(%s) {
81 %s {
82 login
83 repositories(first: $perPage, after: $endCursor, privacy: $privacy, isFork: $fork, ownerAffiliations: OWNER, orderBy: { field: PUSHED_AT, direction: DESC }) {
84 nodes{%s}
85 totalCount
86 pageInfo{hasNextPage,endCursor}
87 }
88 }
89 }`, strings.Join(inputs, ","), ownerConnection, api.RepositoryGraphQL(filter.Fields))

Callers 2

listRunFunction · 0.85

Calls 6

RepositoryGraphQLFunction · 0.92
NewClientFromHTTPFunction · 0.92
searchReposFunction · 0.85
JoinMethod · 0.80
GraphQLMethod · 0.80
StringMethod · 0.45

Tested by 1