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

Function v1Projects

api/queries_repo.go:1517–1551  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 2

ProjectTitlesToPathsFunction · 0.85
RepoMetadataFunction · 0.85

Calls 6

RepoProjectsFunction · 0.85
OrganizationProjectsFunction · 0.85
ContainsMethod · 0.80
ErrorfMethod · 0.65
WaitMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected