mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-02-01 21:31:18 -08:00
23 lines
595 B
Go
23 lines
595 B
Go
|
package segments
|
||
|
|
||
|
import "path/filepath"
|
||
|
|
||
|
// resolveGitPath resolves path relative to base.
|
||
|
func resolveGitPath(base, path string) string {
|
||
|
if len(path) == 0 {
|
||
|
return base
|
||
|
}
|
||
|
if filepath.IsAbs(path) {
|
||
|
return path
|
||
|
}
|
||
|
// Note that git on Windows uses slashes exclusively. And it's okay
|
||
|
// because Windows actually accepts both directory separators. More
|
||
|
// importantly, however, parts of the git segment depend on those
|
||
|
// slashes.
|
||
|
if path[0] == '/' {
|
||
|
// path is a disk-relative path.
|
||
|
return filepath.VolumeName(base) + path
|
||
|
}
|
||
|
return filepath.ToSlash(filepath.Join(base, path))
|
||
|
}
|