(ctx context.Context, org, remote, subPath string)
| 330 | } |
| 331 | |
| 332 | func (h *Helper) ProjectNamesByGitRemote(ctx context.Context, org, remote, subPath string) ([]string, error) { |
| 333 | if org == "" || remote == "" { |
| 334 | return nil, errors.New("org, remote cannot be blank") |
| 335 | } |
| 336 | |
| 337 | c, err := h.Client() |
| 338 | if err != nil { |
| 339 | return nil, err |
| 340 | } |
| 341 | |
| 342 | resp, err := c.ListProjectsForOrganization(ctx, &adminv1.ListProjectsForOrganizationRequest{ |
| 343 | Org: org, |
| 344 | }) |
| 345 | if err != nil { |
| 346 | return nil, err |
| 347 | } |
| 348 | |
| 349 | names := make([]string, 0) |
| 350 | for _, p := range resp.Projects { |
| 351 | if strings.EqualFold(p.GitRemote, remote) && (subPath == "" || strings.EqualFold(p.Subpath, subPath)) { |
| 352 | names = append(names, p.Name) |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | if len(names) == 0 { |
| 357 | return nil, fmt.Errorf("no project with Git remote %q exists in the org %q", remote, org) |
| 358 | } |
| 359 | |
| 360 | return names, nil |
| 361 | } |
| 362 | |
| 363 | // InferProjectName infers a project name from the given path. |
| 364 | // If multiple projects are found, it prompts the user to select one (or errors in non-interactive mode). |
nothing calls this directly
no test coverage detected