MCPcopy Index your code
hub / github.com/rilldata/rill / InferProjects

Method InferProjects

cli/pkg/cmdutil/helper.go:396–465  ·  view source on GitHub ↗
(ctx context.Context, org, path string)

Source from the content-addressed store, hash-verified

394}
395
396func (h *Helper) InferProjects(ctx context.Context, org, path string) ([]*adminv1.Project, error) {
397 path, err := fileutil.ExpandHome(path)
398 if err != nil {
399 return nil, err
400 }
401
402 path, err = filepath.Abs(path)
403 if err != nil {
404 return nil, err
405 }
406
407 // Build request
408 req := &adminv1.ListProjectsForFingerprintRequest{
409 DirectoryName: filepath.Base(path),
410 }
411
412 // extract subpath
413 repoRoot, subpath, err := gitutil.InferRepoRootAndSubpath(path)
414 if err == nil {
415 req.SubPath = subpath
416 }
417
418 // extract remotes
419 remote, err := gitutil.ExtractRemotes(repoRoot, false)
420 if err == nil {
421 for _, r := range remote {
422 if r.Name == "__rill_remote" {
423 req.RillMgdGitRemote = r.URL
424 } else {
425 gitRemote, err := r.Github()
426 if err == nil {
427 req.GitRemote = gitRemote
428 }
429 }
430 }
431 }
432 c, err := h.Client()
433 if err != nil {
434 return nil, err
435 }
436 resp, err := c.ListProjectsForFingerprint(ctx, req)
437 if err != nil {
438 return nil, err
439 }
440 if len(resp.Projects) == 0 {
441 return nil, ErrInferProjectFailed
442 }
443
444 if org == "" {
445 return resp.Projects, nil
446 }
447
448 orgFiltered := make([]*adminv1.Project, 0)
449 for _, p := range resp.Projects {
450 if p.OrgName == org {
451 orgFiltered = append(orgFiltered, p)
452 }
453 }

Callers 11

InferProjectNameMethod · 0.95
GetCurrentProjectMethod · 0.80
ListMatchingProjectsMethod · 0.80
GitStatusMethod · 0.80
GetGithubPullRequestMethod · 0.80
GitPullMethod · 0.80
GitPushMethod · 0.80
GetConfigMethod · 0.80
ListDeploymentsMethod · 0.80

Calls 7

ClientMethod · 0.95
HandleRepoTransferMethod · 0.95
ExpandHomeFunction · 0.92
InferRepoRootAndSubpathFunction · 0.92
ExtractRemotesFunction · 0.92
GithubMethod · 0.80

Tested by

no test coverage detected