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

Function InferRepoRootAndSubpath

cli/pkg/gitutil/gitutil.go:354–381  ·  view source on GitHub ↗

InferRepoRootAndSubpath infers the root of the Git repository and the subpath from the given path. Since the extraction stops at first .git directory it means that if a subpath in a github monorepo is deployed as a rill managed project it will prevent the subpath from being inferred. This means : -

(path string)

Source from the content-addressed store, hash-verified

352// - user will need to explicitly set the subpath if they want to connect this to Github.
353// - When finding matching projects it will only list the rill managed projects for that subpath.
354func InferRepoRootAndSubpath(path string) (string, string, error) {
355 // check if is a git repository
356 repoRoot, err := InferGitRepoRoot(path)
357 if err != nil {
358 return "", "", err
359 }
360
361 // infer subpath if it exists
362 subPath, err := filepath.Rel(repoRoot, path)
363 if err != nil {
364 // should never happen because repoRoot is detected from path
365 return "", "", err
366 }
367 if subPath == "." || subPath == "" {
368 // no subpath
369 return repoRoot, "", nil
370 }
371 // check if subpath is in .gitignore
372 ignored, err := isGitIgnored(repoRoot, subPath)
373 if err != nil {
374 return "", "", err
375 }
376 if ignored {
377 // if subpath is ignored this is not a valid git path
378 return "", "", ErrNotAGitRepository
379 }
380 return repoRoot, subPath, nil
381}

Callers 9

InferProjectsMethod · 0.92
DeployProjectMethod · 0.92
RedeployProjectMethod · 0.92
GitStatusMethod · 0.92
GitPullMethod · 0.92
GitPushMethod · 0.92
redeployProjectFunction · 0.92
loadGitConfigMethod · 0.92

Calls 2

InferGitRepoRootFunction · 0.85
isGitIgnoredFunction · 0.85

Tested by

no test coverage detected