Fix bug detecting if go.mod files are nested

This commit is contained in:
Owen Mansel-Chan
2023-06-28 12:22:46 +01:00
parent 1a80ba0821
commit c766f68b93
2 changed files with 12 additions and 4 deletions

View File

@@ -249,8 +249,16 @@ func getDirs(paths []string) []string {
return dirs
}
// Note this has the side effect of sorting `dirs`
func checkDirsNested(dirs []string) bool {
func checkDirsNested(inputDirs []string) bool {
// replace "." with "" so that we can check if all the paths are nested
dirs := make([]string, len(inputDirs))
for i, inputDir := range inputDirs {
if inputDir == "." {
dirs[i] = ""
} else {
dirs[i] = inputDir
}
}
// the paths were generated by a depth-first search so I think they might
// be sorted, but we sort them just in case
sort.Strings(dirs)