MCPcopy
hub / github.com/cli/cli / mapRepoNamesToIDs

Function mapRepoNamesToIDs

pkg/cmd/secret/set/set.go:435–455  ·  view source on GitHub ↗
(client *api.Client, host, defaultOwner string, repositoryNames []string)

Source from the content-addressed store, hash-verified

433}
434
435func mapRepoNamesToIDs(client *api.Client, host, defaultOwner string, repositoryNames []string) ([]int64, error) {
436 repos := make([]ghrepo.Interface, 0, len(repositoryNames))
437 for _, repositoryName := range repositoryNames {
438 var repo ghrepo.Interface
439 if strings.Contains(repositoryName, "/") || defaultOwner == "" {
440 var err error
441 repo, err = ghrepo.FromFullNameWithHost(repositoryName, host)
442 if err != nil {
443 return nil, fmt.Errorf("invalid repository name: %w", err)
444 }
445 } else {
446 repo = ghrepo.NewWithHost(defaultOwner, repositoryName, host)
447 }
448 repos = append(repos, repo)
449 }
450 repositoryIDs, err := api.GetRepoIDs(client, host, repos)
451 if err != nil {
452 return nil, fmt.Errorf("failed to look up IDs for repositories %v: %w", repositoryNames, err)
453 }
454 return repositoryIDs, nil
455}

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