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

Function ResolveGitRoot

internal/skills/installer/installer.go:311–324  ·  view source on GitHub ↗

ResolveGitRoot returns the git repository root using the provided client, falling back to the current working directory on error.

(gc *git.Client)

Source from the content-addressed store, hash-verified

309// ResolveGitRoot returns the git repository root using the provided client,
310// falling back to the current working directory on error.
311func ResolveGitRoot(gc *git.Client) string {
312 if gc != nil && gc.RepoDir != "" {
313 return gc.RepoDir
314 }
315 if gc != nil {
316 if root, err := gc.ToplevelDir(context.Background()); err == nil {
317 return root
318 }
319 }
320 if cwd, err := os.Getwd(); err == nil {
321 return cwd
322 }
323 return ""
324}
325
326// ResolveHomeDir returns the user's home directory, or "" on error.
327func ResolveHomeDir() string {

Callers 5

updateRunFunction · 0.92
buildScanTargetsFunction · 0.92
installRunFunction · 0.92
runLocalInstallFunction · 0.92
TestResolveGitRootFunction · 0.85

Calls 1

ToplevelDirMethod · 0.80

Tested by 1

TestResolveGitRootFunction · 0.68