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

Function getRepoIds

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

Source from the content-addressed store, hash-verified

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

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