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

Function v1Projects

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

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