Skip to content

Commit

Permalink
cmd/cue: parse module.cue file in non-strict mode
Browse files Browse the repository at this point in the history
We do not want to prevent editing a module.cue file
when the strictness criteria are not met.

Fixes #3211.

Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: I31991846db9a1815eeaa4cc41720e0943e74e4a0
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1196180
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1196234
Reviewed-by: Paul Jolly <paul@myitcv.io>
  • Loading branch information
rogpeppe authored and myitcv committed Jun 12, 2024
1 parent 7ceb629 commit d8742c1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/cue/cmd/modedit.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (c *modEditCmd) run(cmd *Command, args []string) error {
if err != nil {
return err
}
mf, err := modfile.Parse(data, modPath)
mf, err := modfile.ParseNonStrict(data, modPath)
if err != nil {
return err
}
Expand Down
20 changes: 15 additions & 5 deletions cmd/cue/cmd/testdata/script/modedit_nonstrict.txtar
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
# This test checks that cue mod edit works OK even when the
# module file doesn't conform to the strict parsing.
# TODO fix this to pass.
! exec cue mod edit --source self
cmpenv stderr want-stderr
exec cue mod edit --source self
cmp cue.mod/module.cue want-module

-- cue.mod/module.cue --
module: "main.org"
deps: "foo.com": v: "v1.2.3"
language: version: "v0.9.0-alpha.0"
-- want-stderr --
invalid module.cue file $WORK${/}cue.mod${/}module.cue: no major version in "foo.com"
-- want-module --
module: "main.org"
language: {
version: "v0.9.0-alpha.0"
}
source: {
kind: "self"
}
deps: {
"foo.com": {
v: "v1.2.3"
}
}

0 comments on commit d8742c1

Please sign in to comment.