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

Function v1Projects

api/queries_repo.go:1518–1552  ·  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

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