MCPcopy
hub / github.com/cli/cli / getRepoIds

Function getRepoIds

pkg/cmd/variable/set/set.go:288–317  ·  view source on GitHub ↗
(client *api.Client, host, owner string, repositoryNames []string)

Source from the content-addressed store, hash-verified

286}
287
288func getRepoIds(client *api.Client, host, owner string, repositoryNames []string) ([]int64, error) {
289 if len(repositoryNames) == 0 {
290 return nil, nil
291 }
292 repos := make([]ghrepo.Interface, 0, len(repositoryNames))
293 for _, repositoryName := range repositoryNames {
294 if repositoryName == "" {
295 continue
296 }
297 var repo ghrepo.Interface
298 if strings.Contains(repositoryName, "/") || owner == "" {
299 var err error
300 repo, err = ghrepo.FromFullNameWithHost(repositoryName, host)
301 if err != nil {
302 return nil, fmt.Errorf("invalid repository name")
303 }
304 } else {
305 repo = ghrepo.NewWithHost(owner, repositoryName, host)
306 }
307 repos = append(repos, repo)
308 }
309 if len(repos) == 0 {
310 return nil, fmt.Errorf("resetting repositories selected to zero is not supported")
311 }
312 repositoryIDs, err := api.GetRepoIDs(client, host, repos)
313 if err != nil {
314 return nil, fmt.Errorf("failed to look up IDs for repositories %v: %w", repositoryNames, err)
315 }
316 return repositoryIDs, nil
317}

Callers 1

setRunFunction · 0.85

Calls 5

FromFullNameWithHostFunction · 0.92
NewWithHostFunction · 0.92
GetRepoIDsFunction · 0.92
ContainsMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected