Skip to content

Commit

Permalink
cmd/cue: fix mod edit --source self
Browse files Browse the repository at this point in the history
The `cue mod edit --source self` wasn't tested and the logic was wrong, so fix it.

Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: I809c466c7c76efde34046b83f70c58760dd7f3fd
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1193381
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
  • Loading branch information
rogpeppe committed Apr 19, 2024
1 parent dc78c66 commit 4997dff
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/cue/cmd/modedit.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (c *modEditCmd) addEdit(f func(*modfile.File) error) {
}

func (c *modEditCmd) flagSource(arg string) error {
if arg != "git" && arg != "none" {
if arg != "git" && arg != "self" {
return fmt.Errorf("unrecognized source kind %q", arg)
}
c.addEdit(func(f *modfile.File) error {
Expand Down
11 changes: 11 additions & 0 deletions cmd/cue/cmd/testdata/script/modedit_initial.txtar
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
exec cue mod edit --source self
cmp cue.mod/module.cue want-module-0

exec cue mod edit --source git
cmp cue.mod/module.cue want-module-1

Expand All @@ -20,6 +23,14 @@ cmp cue.mod/module.cue want-module-5
-- cue.mod/module.cue --
module: "main.org@v0"
language: version: "v0.9.0-alpha.0"
-- want-module-0 --
module: "main.org@v0"
language: {
version: "v0.9.0-alpha.0"
}
source: {
kind: "self"
}
-- want-module-1 --
module: "main.org@v0"
language: {
Expand Down

0 comments on commit 4997dff

Please sign in to comment.