fix(scm): convert to Windows path with / instead of \

This commit is contained in:
L. Yeung 2022-08-29 21:55:58 +08:00 committed by Jan De Dobbeleer
parent 7e141fb5ec
commit 0b77995d80
4 changed files with 6 additions and 6 deletions

View file

@ -106,7 +106,7 @@ func (env *ShellEnvironment) InWSLSharedDrive() bool {
}
func (env *ShellEnvironment) ConvertToWindowsPath(path string) string {
windowsPath, err := env.RunCommand("wslpath", "-w", path)
windowsPath, err := env.RunCommand("wslpath", "-m", path)
if err == nil {
return windowsPath
}

View file

@ -228,7 +228,7 @@ func (env *ShellEnvironment) InWSLSharedDrive() bool {
}
func (env *ShellEnvironment) ConvertToWindowsPath(path string) string {
return path
return strings.ReplaceAll(path, `\`, "/")
}
func (env *ShellEnvironment) ConvertToLinuxPath(path string) string {

View file

@ -94,10 +94,10 @@ func (s *scm) FileContents(folder, file string) string {
}
func (s *scm) convertToWindowsPath(path string) string {
if !s.IsWslSharedPath {
return path
if s.env.GOOS() == environment.WINDOWS || s.IsWslSharedPath {
return s.env.ConvertToWindowsPath(path)
}
return s.env.ConvertToWindowsPath(path)
return path
}
func (s *scm) convertToLinuxPath(path string) string {

View file

@ -81,7 +81,7 @@ func (s *Svn) shouldDisplay() bool {
s.workingDir = Svndir.Path
s.rootDir = Svndir.Path
// convert the worktree file path to a windows one when in wsl 2 shared folder
s.realDir = strings.TrimSuffix(s.convertToWindowsPath(Svndir.Path), ".svn")
s.realDir = strings.TrimSuffix(s.convertToWindowsPath(Svndir.Path), "/.svn")
return true
}
// handle worktree