mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-28 04:19:41 -08:00
fix(git): align git Dir with PWD
This commit is contained in:
parent
f04e22a5d1
commit
2a1fdffb73
|
@ -726,8 +726,9 @@ func (env *ShellEnvironment) TemplateCache() *TemplateCache {
|
|||
val := splitted[1:]
|
||||
tmplCache.Env[key] = strings.Join(val, separator)
|
||||
}
|
||||
tmplCache.PWD = env.Pwd()
|
||||
tmplCache.Folder = Base(env, tmplCache.PWD)
|
||||
pwd := env.Pwd()
|
||||
tmplCache.PWD = strings.Replace(pwd, env.Home(), "~", 1)
|
||||
tmplCache.Folder = Base(env, pwd)
|
||||
tmplCache.UserName = env.User()
|
||||
if host, err := env.Host(); err == nil {
|
||||
tmplCache.HostName = host
|
||||
|
|
|
@ -160,7 +160,8 @@ func (g *Git) shouldDisplay() bool {
|
|||
}
|
||||
|
||||
// convert the worktree file path to a windows one when in wsl 2 shared folder
|
||||
g.Dir = strings.TrimSuffix(g.convertToWindowsPath(gitdir.Path), "/.git")
|
||||
dir := strings.Replace(gitdir.Path, g.env.Home(), "~", 1) // align with template PWD
|
||||
g.Dir = strings.TrimSuffix(g.convertToWindowsPath(dir), "/.git")
|
||||
|
||||
if !gitdir.IsDir {
|
||||
return g.hasWorktree(gitdir)
|
||||
|
@ -168,7 +169,7 @@ func (g *Git) shouldDisplay() bool {
|
|||
|
||||
g.workingDir = gitdir.Path
|
||||
g.rootDir = gitdir.Path
|
||||
g.realDir = g.Dir
|
||||
g.realDir = strings.TrimSuffix(g.convertToWindowsPath(gitdir.Path), "/.git")
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ func TestEnabledInWorkingDirectory(t *testing.T) {
|
|||
env.On("IsWsl").Return(false)
|
||||
env.On("HasParentFilePath", ".git").Return(fileInfo, nil)
|
||||
env.On("PathSeparator").Return("/")
|
||||
env.On("Home").Return("/Users/posh")
|
||||
g := &Git{
|
||||
scm: scm{
|
||||
env: env,
|
||||
|
|
Loading…
Reference in a new issue