Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change register repository calls to use one call per repo #1429

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions cmd/cli/app/repo/repo_register.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,27 @@ var repo_registerCmd = &cobra.Command{
os.Exit(1)
}

// Construct the RegisterRepositoryRequest
request := &pb.RegisterRepositoryRequest{
Provider: provider,
Repositories: selectedRepos,
ProjectId: projectID,
}
results := []*pb.RegisterRepoResult{}
for idx := range selectedRepos {
repo := selectedRepos[idx]
repoRegList := []*pb.UpstreamRepositoryRef{repo}
// Construct the RegisterRepositoryRequest
request := &pb.RegisterRepositoryRequest{
Provider: provider,
Repositories: repoRegList,
ProjectId: projectID,
}

// Register the repos
registerResp, err := client.RegisterRepository(context.Background(), request)
if err != nil {
_, _ = fmt.Fprintf(os.Stderr, "Error registering repositories: %s\n", err)
os.Exit(1)
result, err := client.RegisterRepository(context.Background(), request)
if err != nil {
_, _ = fmt.Fprintf(os.Stderr, "Error registering repository %s: %s\n", repo.Name, err)
continue
}

results = append(results, result.Results...)
}

// Register the repos
// The result gives a list of repositories with the registration status
// Let's parse the results and print the status
columns := []table.Column{
Expand All @@ -146,8 +153,8 @@ var repo_registerCmd = &cobra.Command{
{Title: "Message", Width: 60},
}

rows := make([]table.Row, len(registerResp.Results))
for i, result := range registerResp.Results {
rows := make([]table.Row, len(results))
for i, result := range results {
rows[i] = table.Row{
fmt.Sprintf("%s/%s", result.Repository.Owner, result.Repository.Name),
}
Expand Down