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