this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

internal/mod/modload: retain source field when tidying

The code to copy the module file from the old version
did not include the source field.

Fixes #3056.

Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: I50505b0c9abf52023e7b4cff73a26cd3a22f7362
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1193708
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>

+22
+17
internal/mod/modload/testdata/tidy/withsource.txtar
··· 1 + # Test that a version is not added or changed if present 2 + -- cue-version -- 3 + v1.2.3 4 + -- want -- 5 + module: "main.org@v0" 6 + language: { 7 + version: "v0.9.0-alpha.2" 8 + } 9 + source: { 10 + kind: "self" 11 + } 12 + -- cue.mod/module.cue -- 13 + module: "main.org@v0" 14 + language: version: "v0.9.0-alpha.2" 15 + source: kind: "self" 16 + -- main.cue -- 17 + package main
+5
internal/mod/modload/tidy.go
··· 130 130 } 131 131 132 132 func modfileFromRequirements(old *modfile.File, rs *modrequirements.Requirements, cueVers string) *modfile.File { 133 + // TODO it would be nice to have some way of automatically including new 134 + // fields by default when they're added to modfile.File, but we don't 135 + // want to just copy the entirety of old because that includes 136 + // private fields too. 133 137 mf := &modfile.File{ 134 138 Module: old.Module, 135 139 Language: old.Language, 136 140 Deps: make(map[string]*modfile.Dep), 141 + Source: old.Source, 137 142 } 138 143 if cueVers != "" && (mf.Language == nil || mf.Language.Version == "") { 139 144 mf.Language = &modfile.Language{