this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

mod/modzip: check for cue.mod existence, not just directories

The codebase is inconsistent about whether cue.mod must be a directory:

- isModRoot() in cue/load/config.go checks existence only, with a comment
noting "cue.mod used to be a file. We still allow both to match."
- Module loading rejects file-based cue.mod with an error message.
- cmd/cue/cmd/modinit.go checks IsDir() and rejects files.

For submodule detection during directory walks, we should be consistent
with isModRoot() and accept either a file or directory. This handles
the case where someone has a legacy cue.mod file marking a submodule.

Simplify the check to just verify cue.mod exists, without requiring
it to be a directory.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I4d089ac6f439057306c0bf2c2992ce5391a59046
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1229772
Reviewed-by: Matthew Sackman <matthew@cue.works>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>

+2 -2
+2 -2
mod/modzip/zip.go
··· 785 785 return filepath.SkipDir 786 786 } 787 787 788 - // Skip submodules (directories containing cue.mod directories). 789 - if cueModInfo, err := os.Lstat(filepath.Join(filePath, "cue.mod")); err == nil && cueModInfo.IsDir() { 788 + // Skip submodules (directories containing cue.mod). 789 + if _, err := os.Lstat(filepath.Join(filePath, "cue.mod")); err == nil { 790 790 omitted = append(omitted, FileError{Path: slashPath, Err: errSubmoduleDir}) 791 791 return filepath.SkipDir 792 792 }