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