v1Projects retrieves set of RepoProjects relevant to given repository: - Projects for repository - Projects for repository organization, if it belongs to one
(client *Client, repo ghrepo.Interface)
| 1507 | // - Projects for repository |
| 1508 | // - Projects for repository organization, if it belongs to one |
| 1509 | func v1Projects(client *Client, repo ghrepo.Interface) ([]RepoProject, error) { |
| 1510 | var repoProjects []RepoProject |
| 1511 | var orgProjects []RepoProject |
| 1512 | |
| 1513 | g, _ := errgroup.WithContext(context.Background()) |
| 1514 | |
| 1515 | g.Go(func() error { |
| 1516 | var err error |
| 1517 | repoProjects, err = RepoProjects(client, repo) |
| 1518 | if err != nil { |
| 1519 | err = fmt.Errorf("error fetching repo projects (classic): %w", err) |
| 1520 | } |
| 1521 | return err |
| 1522 | }) |
| 1523 | |
| 1524 | g.Go(func() error { |
| 1525 | var err error |
| 1526 | orgProjects, err = OrganizationProjects(client, repo) |
| 1527 | if err != nil && !strings.Contains(err.Error(), errorResolvingOrganization) { |
| 1528 | err = fmt.Errorf("error fetching organization projects (classic): %w", err) |
| 1529 | return err |
| 1530 | } |
| 1531 | return nil |
| 1532 | }) |
| 1533 | |
| 1534 | if err := g.Wait(); err != nil { |
| 1535 | return nil, err |
| 1536 | } |
| 1537 | |
| 1538 | projects := make([]RepoProject, 0, len(repoProjects)+len(orgProjects)) |
| 1539 | projects = append(projects, repoProjects...) |
| 1540 | projects = append(projects, orgProjects...) |
| 1541 | |
| 1542 | return projects, nil |
| 1543 | } |
| 1544 | |
| 1545 | // v2Projects retrieves set of ProjectV2 relevant to given repository: |
| 1546 | // - ProjectsV2 owned by current user |
no test coverage detected