From 24fe8c25c3175ab9ceac26981223e22522a21db4 Mon Sep 17 00:00:00 2001 From: Matthew Sackman Date: Fri, 30 Aug 2024 15:14:59 +0100 Subject: [PATCH] cmd/fix: allow fix to load all packages in a directory Unlike `cue eval`, `cue fix` should load and operate on all cue files in a directory, regardless of whether they belong to the same package or not. Fixes #3405 Signed-off-by: Matthew Sackman Change-Id: If79c6d019b9496cfefc833d3fa5e5b6a98ae0ade Dispatch-Trailer: {"type":"trybot","CL":1200351,"patchset":1,"ref":"refs/changes/51/1200351/1","targetBranch":"master"} --- cmd/cue/cmd/fix.go | 5 +++-- cmd/cue/cmd/testdata/script/fix.txtar | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 cmd/cue/cmd/testdata/script/fix.txtar diff --git a/cmd/cue/cmd/fix.go b/cmd/cue/cmd/fix.go index 8c2147d07..ae57c5678 100644 --- a/cmd/cue/cmd/fix.go +++ b/cmd/cue/cmd/fix.go @@ -74,8 +74,9 @@ func runFixAll(cmd *Command, args []string) error { } instances := load.Instances(args, &load.Config{ - Tests: true, - Tools: true, + Tests: true, + Tools: true, + Package: "*", }) errs := fix.Instances(instances, opts...) diff --git a/cmd/cue/cmd/testdata/script/fix.txtar b/cmd/cue/cmd/testdata/script/fix.txtar new file mode 100644 index 000000000..26a77e389 --- /dev/null +++ b/cmd/cue/cmd/testdata/script/fix.txtar @@ -0,0 +1,17 @@ +exec cue fix ./... +cmp good/good.cue good/good.cue.fixed + +-- good/good.cue -- +package good + +out: ["foo"] + ["bar"] +-- good/good.cue.fixed -- +package good + +import list6c6973 "list" + +out: list6c6973.Concat([["foo"], ["bar"]]) +-- bad/bad1.cue -- +package bad1 +-- bad/bad2.cue -- +package bad2