Repository: JanDeDobbeleer/oh-my-posh
Pull request #5232 (2024-07-09 05:46:50)

feat(git): follow symlinks for git dir
### Prerequisites

- [x] I have read and understood the [contributing guide][CONTRIBUTING.md].
- [x] The commit message follows the [conventional commits][cc] guidelines.
- [x] Tests for the changes have been added (for bug fixes / features).
- [x] Docs have been added/updated (for bug fixes / features).

### Description

- **fix(nu): validate config field before manipulation**
- **feat(git): follow symlinks for git dir**

<!---

Tips:

If you're not comfortable with working with Git,
we're working a guide (https://ohmyposh.dev/docs/contributing/git) to help you out.
Oh My Posh advises GitKraken (https://www.gitkraken.com/invite/nQmDPR9D) as your preferred cross platform Git GUI power tool.

-->

[CONTRIBUTING.md]: https://github.com/JanDeDobbeleer/oh-my-posh/blob/main/CONTRIBUTING.md
[cc]: https://www.conventionalcommits.org/en/v1.0.0/#summary



Patch:
diff --git a/src/runtime/mock/environment.go b/src/runtime/mock/environment.go
index 6940fbb6..1fece075 100644
--- a/src/runtime/mock/environment.go
+++ b/src/runtime/mock/environment.go
@@ -152,8 +152,8 @@ func (env *Environment) HTTPRequest(url string, _ io.Reader, _ int, _ ...http.Re
 	return args.Get(0).([]byte), args.Error(1)
 }
 
-func (env *Environment) HasParentFilePath(path string) (*runtime.FileInfo, error) {
-	args := env.Called(path)
+func (env *Environment) HasParentFilePath(parent string, followSymlinks bool) (*runtime.FileInfo, error) {
+	args := env.Called(parent, followSymlinks)
 	return args.Get(0).(*runtime.FileInfo), args.Error(1)
 }
 
diff --git a/src/runtime/os.go b/src/runtime/os.go
index 9e043ce9..c529b6d0 100644
--- a/src/runtime/os.go
+++ b/src/runtime/os.go
@@ -154,7 +154,7 @@ type Environment interface {
 	HasFiles(pattern string) bool
 	HasFilesInDir(dir, pattern string) bool
 	HasFolder(folder string) bool
-	HasParentFilePath(path string) (fileInfo *FileInfo, err error)
+	HasParentFilePath(path string, followSymlinks bool) (fileInfo *FileInfo, err error)
 	HasFileInParentDirs(pattern string, depth uint) bool
 	ResolveSymlink(path string) (string, error)
 	DirMatchesOneOf(dir string, regexes []string) bool
@@ -664,26 +664,36 @@ func (term *Terminal) HTTPRequest(targetURL string, body io.Reader, timeout int,
 	return responseBody, nil
 }
 
-func (term *Terminal) HasParentFilePath(path string) (*FileInfo, error) {
-	defer term.Trace(time.Now(), path)
-	currentFolder := term.Pwd()
+func (term *Terminal) HasParentFilePath(parent string, followSymlinks bool) (*FileInfo, error) {
+	defer term.Trace(time.Now(), parent)
+
+	path := term.Pwd()
+	if followSymlinks {
+		if actual, err := term.ResolveSymlink(path); err == nil {
+			path = actual
+		}
+	}
+
 	for {
-		fileSystem := os.DirFS(currentFolder)
-		info, err := fs.Stat(fileSystem, path)
+		fileSystem := os.DirFS(path)
+		info, err := fs.Stat(fileSystem, parent)
 		if err == nil {
 			return &FileInfo{
-				ParentFolder: currentFolder,
-				Path:         filepath.Join(currentFolder, path),
+				ParentFolder: path,
+				Path:         filepath.Join(path, parent),
 				IsDir:        info.IsDir(),
 			}, nil
 		}
+
 		if !os.IsNotExist(err) {
 			return nil, err
 		}
-		if dir := filepath.Dir(currentFolder); dir != currentFolder {
-			currentFolder = dir
+
+		if dir := filepath.Dir(path); dir != path {
+			path = dir
 			continue
 		}
+
 		term.Error(err)
 		return nil, errors.New("no match at root level")
 	}
diff --git a/src/segments/azd.go b/src/segments/azd.go
index 170862b2..82bc8774 100644
--- a/src/segments/azd.go
+++ b/src/segments/azd.go
@@ -35,7 +35,7 @@ func (t *Azd) Enabled() bool {
 
 	folders := t.props.GetStringArray(LanguageFolders, []string{".azure"})
 	for _, folder := range folders {
-		if file, err := t.env.HasParentFilePath(folder); err == nil {
+		if file, err := t.env.HasParentFilePath(folder, false); err == nil {
 			parentFilePath = file.ParentFolder
 			break
 		}
diff --git a/src/segments/cf_target.go b/src/segments/cf_target.go
index 520813eb..32bb942b 100644
--- a/src/segments/cf_target.go
+++ b/src/segments/cf_target.go
@@ -41,7 +41,7 @@ func (c *CfTarget) Enabled() bool {
 		return c.setCFTargetStatus()
 	}
 
-	manifest, err := c.env.HasParentFilePath("manifest.yml")
+	manifest, err := c.env.HasParentFilePath("manifest.yml", false)
 	if err != nil || manifest.IsDir {
 		return false
 	}
diff --git a/src/segments/git.go b/src/segments/git.go
index c8e1a0a1..bd7fff9a 100644
--- a/src/segments/git.go
+++ b/src/segments/git.go
@@ -279,11 +279,12 @@ func (g *Git) shouldDisplay() bool {
 		return false
 	}
 
-	gitdir, err := g.env.HasParentFilePath(".git")
+	gitdir, err := g.env.HasParentFilePath(".git", true)
 	if err != nil {
 		if !g.props.GetBool(FetchBareInfo, false) {
 			return false
 		}
+
 		g.realDir = g.env.Pwd()
 		bare := g.getGitCommandOutput("rev-parse", "--is-bare-repository")
 		if bare == trueStr {
@@ -291,6 +292,7 @@ func (g *Git) shouldDisplay() bool {
 			g.workingDir = g.realDir
 			return true
 		}
+
 		return false
 	}
 
diff --git a/src/segments/golang.go b/src/segments/golang.go
index e35dfe4b..319782d0 100644
--- a/src/segments/golang.go
+++ b/src/segments/golang.go
@@ -43,7 +43,7 @@ func (g *Golang) getVersion() (string, error) {
 	if !g.props.GetBool(ParseModFile, false) {
 		return "", nil
 	}
-	gomod, err := g.language.env.HasParentFilePath("go.mod")
+	gomod, err := g.language.env.HasParentFilePath("go.mod", false)
 	if err != nil {
 		return "", nil
 	}
diff --git a/src/segments/haskell.go b/src/segments/haskell.go
index 2373728a..dc69ebef 100644
--- a/src/segments/haskell.go
+++ b/src/segments/haskell.go
@@ -46,7 +46,7 @@ func (h *Haskell) Init(props properties.Properties, env runtime.Environment) {
 		h.language.commands = []*cmd{stackGhcCmd}
 		h.StackGhc = true
 	case "package":
-		_, err := h.language.env.HasParentFilePath("stack.yaml")
+		_, err := h.language.env.HasParentFilePath("stack.yaml", false)
 		if err == nil {
 			h.language.commands = []*cmd{stackGhcCmd}
 			h.StackGhc = true
diff --git a/src/segments/helm.go b/src/segments/helm.go
index c69c210e..64a32481 100644
--- a/src/segments/helm.go
+++ b/src/segments/helm.go
@@ -21,7 +21,7 @@ func (h *Helm) Enabled() bool {
 	inChart := false
 	files := []string{"Chart.yml", "Chart.yaml", "helmfile.yaml", "helmfile.yml"}
 	for _, file := range files {
-		if _, err := h.env.HasParentFilePath(file); err == nil {
+		if _, err := h.env.HasParentFilePath(file, false); err == nil {
 			inChart = true
 			break
 		}
diff --git a/src/segments/language.go b/src/segments/language.go
index 8fecc1dd..db17b998 100644
--- a/src/segments/language.go
+++ b/src/segments/language.go
@@ -174,11 +174,12 @@ func (l *language) hasLanguageFiles() bool {
 
 func (l *language) hasProjectFiles() bool {
 	for _, extension := range l.projectFiles {
-		if configPath, err := l.env.HasParentFilePath(extension); err == nil {
+		if configPath, err := l.env.HasParentFilePath(extension, false); err == nil {
 			l.projectRoot = configPath
 			return true
 		}
 	}
+
 	return false
 }
 
diff --git a/src/segments/mercurial.go b/src/segments/mercurial.go
index 7e7f31e0..5b07185d 100644
--- a/src/segments/mercurial.go
+++ b/src/segments/mercurial.go
@@ -67,7 +67,7 @@ func (hg *Mercurial) shouldDisplay() bool {
 		return false
 	}
 
-	hgdir, err := hg.env.HasParentFilePath(".hg")
+	hgdir, err := hg.env.HasParentFilePath(".hg", false)
 	if err != nil {
 		return false
 	}
diff --git a/src/segments/path.go b/src/segments/path.go
index df5d4ff6..c6479fe0 100644
--- a/src/segments/path.go
+++ b/src/segments/path.go
@@ -839,7 +839,7 @@ func (pt *Path) makeFolderFormatMap() map[string]string {
 	folderFormatMap := make(map[string]string)
 
 	if gitDirFormat := pt.props.GetString(GitDirFormat, ""); len(gitDirFormat) != 0 {
-		dir, err := pt.env.HasParentFilePath(".git")
+		dir, err := pt.env.HasParentFilePath(".git", false)
 		if err == nil && dir.IsDir {
 			folderFormatMap[dir.ParentFolder] = gitDirFormat
 		}
diff --git a/src/segments/plastic.go b/src/segments/plastic.go
index 9d9e1f13..07c0faee 100644
--- a/src/segments/plastic.go
+++ b/src/segments/plastic.go
@@ -51,13 +51,16 @@ func (p *Plastic) Enabled() bool {
 	if !p.env.HasCommand("cm") {
 		return false
 	}
-	wkdir, err := p.env.HasParentFilePath(".plastic")
+
+	wkdir, err := p.env.HasParentFilePath(".plastic", false)
 	if err != nil {
 		return false
 	}
+
 	if p.shouldIgnoreRootRepository(wkdir.ParentFolder) {
 		return false
 	}
+
 	if !wkdir.IsDir {
 		return false
 	}
diff --git a/src/segments/sapling.go b/src/segments/sapling.go
index 47a1e48a..e756400c 100644
--- a/src/segments/sapling.go
+++ b/src/segments/sapling.go
@@ -76,7 +76,7 @@ func (sl *Sapling) shouldDisplay() bool {
 		return false
 	}
 
-	slDir, err := sl.env.HasParentFilePath(".sl")
+	slDir, err := sl.env.HasParentFilePath(".sl", false)
 	if err != nil {
 		return false
 	}
@@ -91,6 +91,7 @@ func (sl *Sapling) shouldDisplay() bool {
 	sl.realDir = strings.TrimSuffix(sl.convertToWindowsPath(slDir.Path), "/.sl")
 	sl.RepoName = runtime.Base(sl.env, sl.convertToLinuxPath(sl.realDir))
 	sl.setDir(slDir.Path)
+
 	return true
 }
 
diff --git a/src/segments/svn.go b/src/segments/svn.go
index c8be0c06..4121203d 100644
--- a/src/segments/svn.go
+++ b/src/segments/svn.go
@@ -65,7 +65,7 @@ func (s *Svn) shouldDisplay() bool {
 		return false
 	}
 
-	Svndir, err := s.env.HasParentFilePath(".svn")
+	Svndir, err := s.env.HasParentFilePath(".svn", false)
 	if err != nil {
 		return false
 	}
diff --git a/src/segments/umbraco.go b/src/segments/umbraco.go
index ea9b5869..2b2a2f7d 100644
--- a/src/segments/umbraco.go
+++ b/src/segments/umbraco.go
@@ -37,7 +37,7 @@ func (u *Umbraco) Enabled() bool {
 	// Check if we have a folder called Umbraco or umbraco in the current directory or a parent directory
 	folders := []string{"umbraco", "Umbraco"}
 	for _, folder := range folders {
-		if file, err := u.env.HasParentFilePath(folder); err == nil {
+		if file, err := u.env.HasParentFilePath(folder, false); err == nil {
 			location = file.ParentFolder
 			break
 		}
diff --git a/src/segments/unity.go b/src/segments/unity.go
index 4d64d205..7acf3a00 100644
--- a/src/segments/unity.go
+++ b/src/segments/unity.go
@@ -40,7 +40,7 @@ func (u *Unity) Enabled() bool {
 }
 
 func (u *Unity) GetUnityVersion() (string, error) {
-	projectDir, err := u.env.HasParentFilePath("ProjectSettings")
+	projectDir, err := u.env.HasParentFilePath("ProjectSettings", false)
 	if err != nil {
 		u.env.Debug("No ProjectSettings parent folder found")
 		return "", err
diff --git a/src/shell/scripts/omp.nu b/src/shell/scripts/omp.nu
index 52d58242..b9a043d2 100644
--- a/src/shell/scripts/omp.nu
+++ b/src/shell/scripts/omp.nu
@@ -1,4 +1,7 @@
-$env.config = ($env.config | upsert render_right_prompt_on_last_line true)
+# make sure we have the right prompt render correctly
+if ($env.config? | is-not-empty) {
+    $env.config = ($env.config | upsert render_right_prompt_on_last_line true)
+}
 
 $env.POWERLINE_COMMAND = 'oh-my-posh'
 $env.POSH_THEME = ::CONFIG::


Test patch:
diff --git a/src/segments/azd_test.go b/src/segments/azd_test.go
index 19d764ff..901dabc6 100644
--- a/src/segments/azd_test.go
+++ b/src/segments/azd_test.go
@@ -44,7 +44,7 @@ func TestAzdSegment(t *testing.T) {
 				ParentFolder: "test",
 				IsDir:        true,
 			}
-			env.On("HasParentFilePath", ".azure").Return(fileInfo, nil)
+			env.On("HasParentFilePath", ".azure", false).Return(fileInfo, nil)
 			dirEntries := []fs.DirEntry{
 				&MockDirEntry{
 					name:  "config.json",
@@ -58,7 +58,7 @@ func TestAzdSegment(t *testing.T) {
 
 			env.On("FileContent", filepath.Join("test", ".azure", "config.json")).Return(`{"version": 1, "defaultEnvironment": "TestEnvironment"}`, nil)
 		} else {
-			env.On("HasParentFilePath", ".azure").Return(&runtime.FileInfo{}, errors.New("no such file or directory"))
+			env.On("HasParentFilePath", ".azure", false).Return(&runtime.FileInfo{}, errors.New("no such file or directory"))
 		}
 
 		azd := Azd{
diff --git a/src/segments/cf_target_test.go b/src/segments/cf_target_test.go
index c3975425..1d409197 100644
--- a/src/segments/cf_target_test.go
+++ b/src/segments/cf_target_test.go
@@ -73,7 +73,7 @@ func TestCFTargetSegment(t *testing.T) {
 		if tc.FileInfo == nil {
 			err = errors.New("no such file or directory")
 		}
-		env.On("HasParentFilePath", "manifest.yml").Return(tc.FileInfo, err)
+		env.On("HasParentFilePath", "manifest.yml", false).Return(tc.FileInfo, err)
 
 		cfTarget := &CfTarget{}
 		props := properties.Map{
diff --git a/src/segments/git_test.go b/src/segments/git_test.go
index 1273db7e..dfdf66e6 100644
--- a/src/segments/git_test.go
+++ b/src/segments/git_test.go
@@ -51,7 +51,7 @@ func TestEnabledInWorkingDirectory(t *testing.T) {
 	env.On("FileContent", "/dir/hello/HEAD").Return("")
 	env.MockGitCommand(fileInfo.Path, "", "describe", "--tags", "--exact-match")
 	env.On("IsWsl").Return(false)
-	env.On("HasParentFilePath", ".git").Return(fileInfo, nil)
+	env.On("HasParentFilePath", ".git", true).Return(fileInfo, nil)
 	env.On("PathSeparator").Return("/")
 	env.On("Home").Return(poshHome)
 	env.On("Getenv", poshGitEnv).Return("")
@@ -192,7 +192,7 @@ func TestEnabledInBareRepo(t *testing.T) {
 		env.On("InWSLSharedDrive").Return(false)
 		env.On("GOOS").Return("")
 		env.On("HasCommand", "git").Return(true)
-		env.On("HasParentFilePath", ".git").Return(&runtime.FileInfo{}, errors.New("nope"))
+		env.On("HasParentFilePath", ".git", true).Return(&runtime.FileInfo{}, errors.New("nope"))
 		env.MockGitCommand(pwd, tc.IsBare, "rev-parse", "--is-bare-repository")
 		env.On("Pwd").Return(pwd)
 		env.On("FileContent", "/home/user/bare.git/HEAD").Return(tc.HEAD)
diff --git a/src/segments/golang_test.go b/src/segments/golang_test.go
index 1e2dc55c..5b068447 100644
--- a/src/segments/golang_test.go
+++ b/src/segments/golang_test.go
@@ -51,7 +51,7 @@ func TestGolang(t *testing.T) {
 			if !tc.HasModFileInParentDir {
 				err = errors.New("no match")
 			}
-			env.On("HasParentFilePath", "go.mod").Return(fileInfo, err)
+			env.On("HasParentFilePath", "go.mod", false).Return(fileInfo, err)
 			var content string
 			if tc.InvalidModfile {
 				content = "invalid go.mod file"
diff --git a/src/segments/haskell_test.go b/src/segments/haskell_test.go
index 522dc5e1..e72600f2 100644
--- a/src/segments/haskell_test.go
+++ b/src/segments/haskell_test.go
@@ -74,9 +74,9 @@ func TestHaskell(t *testing.T) {
 
 		if tc.InStackPackage {
 			var err error
-			env.On("HasParentFilePath", "stack.yaml").Return(fileInfo, err)
+			env.On("HasParentFilePath", "stack.yaml", false).Return(fileInfo, err)
 		} else {
-			env.On("HasParentFilePath", "stack.yaml").Return(fileInfo, errors.New("no match"))
+			env.On("HasParentFilePath", "stack.yaml", false).Return(fileInfo, errors.New("no match"))
 		}
 
 		props[StackGhcMode] = tc.StackGhcMode
diff --git a/src/segments/helm_test.go b/src/segments/helm_test.go
index 45fa9adc..219d2099 100644
--- a/src/segments/helm_test.go
+++ b/src/segments/helm_test.go
@@ -86,8 +86,8 @@ func TestHelmSegment(t *testing.T) {
 		env.On("HasCommand", "helm").Return(tc.HelmExists)
 		env.On("RunCommand", "helm", []string{"version", "--short", "--template={{.Version}}"}).Return("v3.12.3", nil)
 
-		env.On("HasParentFilePath", tc.ChartFile).Return(&runtime.FileInfo{}, nil)
-		env.On("HasParentFilePath", testify_mock.Anything).Return(&runtime.FileInfo{}, errors.New("no such file or directory"))
+		env.On("HasParentFilePath", tc.ChartFile, false).Return(&runtime.FileInfo{}, nil)
+		env.On("HasParentFilePath", testify_mock.Anything, false).Return(&runtime.FileInfo{}, errors.New("no such file or directory"))
 
 		props := properties.Map{
 			DisplayMode: tc.DisplayMode,
diff --git a/src/segments/mercurial_test.go b/src/segments/mercurial_test.go
index bb671bf9..6e7114ec 100644
--- a/src/segments/mercurial_test.go
+++ b/src/segments/mercurial_test.go
@@ -37,7 +37,7 @@ func TestMercurialEnabledInWorkingDirectory(t *testing.T) {
 	env.On("HasCommand", "hg").Return(true)
 	env.On("GOOS").Return("")
 	env.On("IsWsl").Return(false)
-	env.On("HasParentFilePath", ".hg").Return(fileInfo, nil)
+	env.On("HasParentFilePath", ".hg", false).Return(fileInfo, nil)
 	env.On("PathSeparator").Return("/")
 	env.On("Home").Return(poshHome)
 	env.On("Getenv", poshGitEnv).Return("")
@@ -151,7 +151,7 @@ A Added.File
 		env.On("HasCommand", "hg").Return(true)
 		env.On("GOOS").Return("")
 		env.On("IsWsl").Return(false)
-		env.On("HasParentFilePath", ".hg").Return(fileInfo, nil)
+		env.On("HasParentFilePath", ".hg", false).Return(fileInfo, nil)
 		env.On("PathSeparator").Return("/")
 		env.On("Home").Return(poshHome)
 		env.On("Getenv", poshGitEnv).Return("")
diff --git a/src/segments/path_test.go b/src/segments/path_test.go
index ab944f19..e118c3eb 100644
--- a/src/segments/path_test.go
+++ b/src/segments/path_test.go
@@ -1609,7 +1609,7 @@ func TestSplitPath(t *testing.T) {
 	for _, tc := range cases {
 		env := new(mock.Environment)
 		env.On("Home").Return("/a/b")
-		env.On("HasParentFilePath", ".git").Return(tc.GitDir, nil)
+		env.On("HasParentFilePath", ".git", false).Return(tc.GitDir, nil)
 		env.On("GOOS").Return(tc.GOOS)
 
 		path := &Path{
diff --git a/src/segments/plastic_test.go b/src/segments/plastic_test.go
index 64eb8064..bfb49a86 100644
--- a/src/segments/plastic_test.go
+++ b/src/segments/plastic_test.go
@@ -35,7 +35,7 @@ func TestPlasticEnabledInWorkspaceDirectory(t *testing.T) {
 		ParentFolder: "/dir",
 		IsDir:        true,
 	}
-	env.On("HasParentFilePath", ".plastic").Return(fileInfo, nil)
+	env.On("HasParentFilePath", ".plastic", false).Return(fileInfo, nil)
 	p := &Plastic{
 		scm: scm{
 			env:   env,
diff --git a/src/segments/python_test.go b/src/segments/python_test.go
index 20287e5f..48ef25fe 100644
--- a/src/segments/python_test.go
+++ b/src/segments/python_test.go
@@ -140,7 +140,7 @@ func TestPythonPythonInContext(t *testing.T) {
 		env.On("Getenv", "CONDA_ENV_PATH").Return("")
 		env.On("Getenv", "CONDA_DEFAULT_ENV").Return("")
 		env.On("Getenv", "PYENV_VERSION").Return("")
-		env.On("HasParentFilePath", ".python-version").Return(&runtime.FileInfo{}, errors.New("no match at root level"))
+		env.On("HasParentFilePath", ".python-version", false).Return(&runtime.FileInfo{}, errors.New("no match at root level"))
 		python := &Python{}
 		python.Init(properties.Map{}, env)
 		python.loadContext()
@@ -188,7 +188,7 @@ func TestPythonVirtualEnvIgnoreDefaultVenvNames(t *testing.T) {
 		env.On("Getenv", "CONDA_ENV_PATH").Return("")
 		env.On("Getenv", "CONDA_DEFAULT_ENV").Return("")
 		env.On("Getenv", "PYENV_VERSION").Return("")
-		env.On("HasParentFilePath", ".python-version").Return(&runtime.FileInfo{}, errors.New("no match at root level"))
+		env.On("HasParentFilePath", ".python-version", false).Return(&runtime.FileInfo{}, errors.New("no match at root level"))
 
 		props[FolderNameFallback] = tc.FolderNameFallback
 
diff --git a/src/segments/quasar_test.go b/src/segments/quasar_test.go
index 92116345..d9df9174 100644
--- a/src/segments/quasar_test.go
+++ b/src/segments/quasar_test.go
@@ -65,7 +65,7 @@ func TestQuasar(t *testing.T) {
 
 		env.On("HasFilesInDir", "/usr/home/project", "package-lock.json").Return(tc.HasPackageLockFile)
 		fileInfo := &runtime.FileInfo{ParentFolder: "/usr/home/project", IsDir: true}
-		env.On("HasParentFilePath", "quasar.config").Return(fileInfo, nil)
+		env.On("HasParentFilePath", "quasar.config", false).Return(fileInfo, nil)
 		env.On("FileContent", filepath.Join(fileInfo.ParentFolder, "package-lock.json")).Return(packageLockFile)
 
 		props[FetchDependencies] = tc.FetchDependencies
diff --git a/src/segments/sapling_test.go b/src/segments/sapling_test.go
index 9bc873d5..bdcf2227 100644
--- a/src/segments/sapling_test.go
+++ b/src/segments/sapling_test.go
@@ -158,9 +158,9 @@ func TestShouldDisplay(t *testing.T) {
 		env.On("Home").Return("/usr/home/sapling")
 		env.On("DirMatchesOneOf", fileInfo.ParentFolder, []string{"/sapling/repo"}).Return(tc.Excluded)
 		if tc.InRepo {
-			env.On("HasParentFilePath", ".sl").Return(fileInfo, nil)
+			env.On("HasParentFilePath", ".sl", false).Return(fileInfo, nil)
 		} else {
-			env.On("HasParentFilePath", ".sl").Return(&runtime.FileInfo{}, errors.New("error"))
+			env.On("HasParentFilePath", ".sl", false).Return(&runtime.FileInfo{}, errors.New("error"))
 		}
 		sl := &Sapling{
 			scm: scm{
diff --git a/src/segments/svn_test.go b/src/segments/svn_test.go
index 13f95700..4b615c3b 100644
--- a/src/segments/svn_test.go
+++ b/src/segments/svn_test.go
@@ -40,7 +40,7 @@ func TestSvnEnabledInWorkingDirectory(t *testing.T) {
 	env.On("RunCommand", "svn", []string{"info", "/dir/hello", "--show-item", "revision"}).Return("", nil)
 	env.On("RunCommand", "svn", []string{"info", "/dir/hello", "--show-item", "relative-url"}).Return("", nil)
 	env.On("IsWsl").Return(false)
-	env.On("HasParentFilePath", ".svn").Return(fileInfo, nil)
+	env.On("HasParentFilePath", ".svn", false).Return(fileInfo, nil)
 	s := &Svn{
 		scm: scm{
 			env:   env,
@@ -237,7 +237,7 @@ R       Moved.File`,
 		env.On("GOOS").Return("")
 		env.On("FileContent", "/dir/hello/trunk").Return("")
 		env.MockSvnCommand(fileInfo.Path, "", "info", "--tags", "--exact-match")
-		env.On("HasParentFilePath", ".svn").Return(fileInfo, nil)
+		env.On("HasParentFilePath", ".svn", false).Return(fileInfo, nil)
 		env.On("RunCommand", "svn", []string{"info", "", "--show-item", "revision"}).Return(tc.RefOutput, nil)
 		env.On("RunCommand", "svn", []string{"info", "", "--show-item", "relative-url"}).Return(tc.BranchOutput, nil)
 		env.On("RunCommand", "svn", []string{"status", ""}).Return(tc.StatusOutput, nil)
diff --git a/src/segments/umbraco_test.go b/src/segments/umbraco_test.go
index 3df7c45c..8f28642c 100644
--- a/src/segments/umbraco_test.go
+++ b/src/segments/umbraco_test.go
@@ -145,10 +145,10 @@ func TestUmbracoSegment(t *testing.T) {
 				IsDir:        true,
 			}
 
-			env.On("HasParentFilePath", "umbraco").Return(fileInfo, nil)
+			env.On("HasParentFilePath", "umbraco", false).Return(fileInfo, nil)
 		} else {
-			env.On("HasParentFilePath", "Umbraco").Return(&runtime.FileInfo{}, errors.New("no such file or directory"))
-			env.On("HasParentFilePath", "umbraco").Return(&runtime.FileInfo{}, errors.New("no such file or directory"))
+			env.On("HasParentFilePath", "Umbraco", false).Return(&runtime.FileInfo{}, errors.New("no such file or directory"))
+			env.On("HasParentFilePath", "umbraco", false).Return(&runtime.FileInfo{}, errors.New("no such file or directory"))
 		}
 
 		dirEntries := []fs.DirEntry{}
diff --git a/src/segments/unity_test.go b/src/segments/unity_test.go
index 0f70c86b..e5e2e270 100644
--- a/src/segments/unity_test.go
+++ b/src/segments/unity_test.go
@@ -98,7 +98,7 @@ func TestUnitySegment(t *testing.T) {
 			versionFilePath := filepath.Join(projectDir.Path, "ProjectVersion.txt")
 			env.On("FileContent", versionFilePath).Return(tc.VersionFileText)
 		}
-		env.On("HasParentFilePath", "ProjectSettings").Return(projectDir, err)
+		env.On("HasParentFilePath", "ProjectSettings", false).Return(projectDir, err)
 
 		props := properties.Map{}
 		unity := &Unity{}
@@ -233,7 +233,7 @@ func TestUnitySegmentCSharpWebRequest(t *testing.T) {
 			versionFilePath := filepath.Join(projectDir.Path, "ProjectVersion.txt")
 			env.On("FileContent", versionFilePath).Return(tc.VersionFileText)
 		}
-		env.On("HasParentFilePath", "ProjectSettings").Return(projectDir, err)
+		env.On("HasParentFilePath", "ProjectSettings", false).Return(projectDir, err)
 
 		cache := &cache_.Cache{}
 		cache.On("Get", tc.CacheGet.key).Return(tc.CacheGet.val, tc.CacheGet.found)