MCPcopy
hub / github.com/cli/cli / NetworkRepos

Method NetworkRepos

context/context.go:132–162  ·  view source on GitHub ↗

NetworkRepos fetches info about remotes for the network of repos. Pass a value of 0 to fetch info on all remotes.

(remotesForLookup int)

Source from the content-addressed store, hash-verified

130// NetworkRepos fetches info about remotes for the network of repos.
131// Pass a value of 0 to fetch info on all remotes.
132func (r *ResolvedRemotes) NetworkRepos(remotesForLookup int) ([]*api.Repository, error) {
133 if r.network == nil {
134 err := resolveNetwork(r, remotesForLookup)
135 if err != nil {
136 return nil, err
137 }
138 }
139
140 var repos []*api.Repository
141 repoMap := map[string]bool{}
142
143 add := func(r *api.Repository) {
144 fn := ghrepo.FullName(r)
145 if _, ok := repoMap[fn]; !ok {
146 repoMap[fn] = true
147 repos = append(repos, r)
148 }
149 }
150
151 for _, repo := range r.network.Repositories {
152 if repo == nil {
153 continue
154 }
155 if repo.Parent != nil {
156 add(repo.Parent)
157 }
158 add(repo)
159 }
160
161 return repos, nil
162}
163
164// RemoteForRepo finds the git remote that points to a repository
165func (r *ResolvedRemotes) RemoteForRepo(repo ghrepo.Interface) (*Remote, error) {

Callers 2

BaseRepoMethod · 0.95
setDefaultRunFunction · 0.80

Calls 2

FullNameFunction · 0.92
resolveNetworkFunction · 0.85

Tested by

no test coverage detected