this repo has no description
0
fork

Configure Feed

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

mod/modfile: deprecate LatestKnownSchemaVersion

The "latest known schema version" is defined to be the
current language version which is now available as part
of the cue API. This function is not used, so deprecate
it, making it return `cueversion.LanguageVersion()` instead.

Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: Ie77d8225fbc5e12c888a7bff3d453c6e061fdf0f
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1196821
Reviewed-by: Paul Jolly <paul@myitcv.io>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>

+16 -16
+14 -15
mod/modfile/modfile.go
··· 232 232 // should be at least this, because that's when we added the language.version 233 233 // field itself. 234 234 func EarliestClosedSchemaVersion() string { 235 - return schemaVersionLimits()[0] 235 + return earliestClosedSchemaVersion() 236 236 } 237 237 238 - // LatestKnownSchemaVersion returns the language version 239 - // associated with the most recent known schema. 240 - func LatestKnownSchemaVersion() string { 241 - return schemaVersionLimits()[1] 242 - } 243 - 244 - var schemaVersionLimits = sync.OnceValue(func() [2]string { 245 - limits, _ := moduleSchemaDo(func(info *schemaInfo) ([2]string, error) { 238 + var earliestClosedSchemaVersion = sync.OnceValue(func() string { 239 + earliest, _ := moduleSchemaDo(func(info *schemaInfo) (string, error) { 246 240 earliest := "" 247 - latest := "" 248 241 for v := range info.Versions { 249 242 if earliest == "" || semver.Compare(v, earliest) < 0 { 250 243 earliest = v 251 244 } 252 - if latest == "" || semver.Compare(v, latest) > 0 { 253 - latest = v 254 - } 255 245 } 256 - return [2]string{earliest, latest}, nil 246 + return earliest, nil 257 247 }) 258 - return limits 248 + return earliest 259 249 }) 250 + 251 + // LatestKnownSchemaVersion returns the language version 252 + // associated with the most recent known schema. 253 + // 254 + // Deprecated: use [cuelang.org/go/cue.LanguageVersion] instead. This 255 + // function will be removed in v0.11. 256 + func LatestKnownSchemaVersion() string { 257 + return cueversion.LanguageVersion() 258 + } 260 259 261 260 // Parse verifies that the module file has correct syntax 262 261 // and follows the schema following the required language.version field.
+2 -1
mod/modfile/modfile_test.go
··· 23 23 24 24 "cuelang.org/go/cue/errors" 25 25 "cuelang.org/go/internal/cuetest" 26 + "cuelang.org/go/internal/cueversion" 26 27 "cuelang.org/go/mod/module" 27 28 ) 28 29 ··· 545 546 } 546 547 547 548 func TestLatestKnownSchemaVersion(t *testing.T) { 548 - qt.Assert(t, qt.Equals(LatestKnownSchemaVersion(), "v0.9.0-alpha.0")) 549 + qt.Assert(t, qt.Equals(LatestKnownSchemaVersion(), cueversion.LanguageVersion())) 549 550 } 550 551 551 552 func parseVersions(vs ...string) []module.Version {