Skip to content

Commit d8742c1

Browse files
rogpeppemyitcv
authored andcommitted
cmd/cue: parse module.cue file in non-strict mode
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 <[email protected]> Change-Id: I31991846db9a1815eeaa4cc41720e0943e74e4a0 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1196180 TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Daniel Martí <[email protected]> Unity-Result: CUE porcuepine <[email protected]> Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1196234 Reviewed-by: Paul Jolly <[email protected]>
1 parent 7ceb629 commit d8742c1

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

cmd/cue/cmd/modedit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func (c *modEditCmd) run(cmd *Command, args []string) error {
7777
if err != nil {
7878
return err
7979
}
80-
mf, err := modfile.Parse(data, modPath)
80+
mf, err := modfile.ParseNonStrict(data, modPath)
8181
if err != nil {
8282
return err
8383
}
Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
# This test checks that cue mod edit works OK even when the
22
# module file doesn't conform to the strict parsing.
3-
# TODO fix this to pass.
4-
! exec cue mod edit --source self
5-
cmpenv stderr want-stderr
3+
exec cue mod edit --source self
4+
cmp cue.mod/module.cue want-module
65

76
-- cue.mod/module.cue --
87
module: "main.org"
98
deps: "foo.com": v: "v1.2.3"
109
language: version: "v0.9.0-alpha.0"
11-
-- want-stderr --
12-
invalid module.cue file $WORK${/}cue.mod${/}module.cue: no major version in "foo.com"
10+
-- want-module --
11+
module: "main.org"
12+
language: {
13+
version: "v0.9.0-alpha.0"
14+
}
15+
source: {
16+
kind: "self"
17+
}
18+
deps: {
19+
"foo.com": {
20+
v: "v1.2.3"
21+
}
22+
}

0 commit comments

Comments
 (0)