-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mod/modfile: always allow missing major version in module field
See issue #3217 for background context. This updates the module logic to always allow a missing major version in the cue.mod module field, and changes `cue mod tidy` and `cue mod fix` so that they don't add one if not already present. When the version is missing, it's assumed to be `v0`. Note that this now allows `cue mod publish` to publish a module that does not contain a major version suffix in its module field. This is a breaking change to the `mod/modfile` API for the reasons explained below. The current invariant for `modfile.File` is that the `Module` field is either empty or a well-formed module path including the major version. This change breaks that invariant, but our judgement is that this is relatively new API and that it should affect very few clients if any (and the fix is easy: change `.Module` to `.QualifiedModule`). Given that this is relatively new API, this should hopefully not break too many clients (and the fix is trivial - just change `.Module` to `.Module()`). Note: a more comprehensive change, and one we should consider for the future, is to use an approach like Go's modfile package (https://pkg.go.dev/golang.org/x/mod/modfile#File) and distinguish the parsed version from the syntax that it was created from. Fixes #3217. Signed-off-by: Roger Peppe <[email protected]> Change-Id: Ib35c84cb608b4441a8578565905778eda5ed49b1 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1196176 Unity-Result: CUE porcuepine <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Daniel Martí <[email protected]>
- Loading branch information
Showing
18 changed files
with
134 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
cmd/cue/cmd/testdata/script/modtidy_missing_major_version.txtar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Check that cue mod tidy does not add a major | ||
# version suffix to the module field unless it is | ||
# already present. | ||
|
||
exec cue mod tidy --check | ||
exec cue mod tidy | ||
cmp cue.mod/module.cue want-cue.mod | ||
-- want-cue.mod -- | ||
module: "main.org" | ||
language: { | ||
version: "v0.8.100" | ||
} | ||
-- cue.mod/module.cue -- | ||
module: "main.org" | ||
language: version: "v0.8.100" | ||
|
||
-- main.cue -- | ||
package main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.