mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-31 13:57:26 -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:]
|
val := splitted[1:]
|
||||||
tmplCache.Env[key] = strings.Join(val, separator)
|
tmplCache.Env[key] = strings.Join(val, separator)
|
||||||
}
|
}
|
||||||
tmplCache.PWD = env.Pwd()
|
pwd := env.Pwd()
|
||||||
tmplCache.Folder = Base(env, tmplCache.PWD)
|
tmplCache.PWD = strings.Replace(pwd, env.Home(), "~", 1)
|
||||||
|
tmplCache.Folder = Base(env, pwd)
|
||||||
tmplCache.UserName = env.User()
|
tmplCache.UserName = env.User()
|
||||||
if host, err := env.Host(); err == nil {
|
if host, err := env.Host(); err == nil {
|
||||||
tmplCache.HostName = host
|
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
|
// 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 {
|
if !gitdir.IsDir {
|
||||||
return g.hasWorktree(gitdir)
|
return g.hasWorktree(gitdir)
|
||||||
|
@ -168,7 +169,7 @@ func (g *Git) shouldDisplay() bool {
|
||||||
|
|
||||||
g.workingDir = gitdir.Path
|
g.workingDir = gitdir.Path
|
||||||
g.rootDir = gitdir.Path
|
g.rootDir = gitdir.Path
|
||||||
g.realDir = g.Dir
|
g.realDir = strings.TrimSuffix(g.convertToWindowsPath(gitdir.Path), "/.git")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ func TestEnabledInWorkingDirectory(t *testing.T) {
|
||||||
env.On("IsWsl").Return(false)
|
env.On("IsWsl").Return(false)
|
||||||
env.On("HasParentFilePath", ".git").Return(fileInfo, nil)
|
env.On("HasParentFilePath", ".git").Return(fileInfo, nil)
|
||||||
env.On("PathSeparator").Return("/")
|
env.On("PathSeparator").Return("/")
|
||||||
|
env.On("Home").Return("/Users/posh")
|
||||||
g := &Git{
|
g := &Git{
|
||||||
scm: scm{
|
scm: scm{
|
||||||
env: env,
|
env: env,
|
||||||
|
|
Loading…
Reference in a new issue