this repo has no description
0
fork

Configure Feed

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

all: start using "else" in comprehensions

Some of these are straightforward changes, with a few exceptions:

* gerrithub.cue was using true/false as values,
so use the conditional as the value directly

* fields using the "switch" list trick with [0] still need to use
a struct embedding the if/else comprehension,
as we cannot use a comprehension directly as a value expression.

* github.cue uses a let with a comprehension in an interpolation;
this works when using the list index trick,
but breaks when embedding in a struct, which seems like a bug.
Add a TODO and we can investigate this later.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I30d890bcaa3b57bf6731fe67d9d1ffb099b098bc
Reviewed-on: https://cue.gerrithub.io/c/cue-lang/cue/+/1231222
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Marcel van Lohuizen <mpvl@gmail.com>

+15 -15
+1 -1
cue.mod/module.cue
··· 1 1 module: "cuelang.org/go" 2 2 language: { 3 - version: "v0.15.0" 3 + version: "v0.16.0" 4 4 }
+1 -2
encoding/jsonschema/crd.cue
··· 23 23 #CRDSpec 24 24 }, 25 25 ] 26 - } 27 - if (input & [...]) == _|_ { 26 + } else { 28 27 // It's a single document. Include it if it looks like a CRD. 29 28 if (input & {#crdlike, ...}) != _|_ { 30 29 [{input, #CRDSpec}]
+1 -1
internal/ci/base/gerrithub.cue
··· 50 50 (trybot.key): { 51 51 "runs-on": linuxSmallMachine + overrideCacheTagDispatch 52 52 53 - let goodDummyData = [if json.Marshal(#dummyDispatch) != _|_ {true}, false][0] 53 + let goodDummyData = json.Marshal(#dummyDispatch) != _|_ 54 54 55 55 // We set the "on" conditions above, but this would otherwise mean we 56 56 // run for all dispatch events.
+7 -5
internal/ci/base/github.cue
··· 243 243 244 244 staticcheck: githubactions.#Step & { 245 245 #in: modfile: string | *"" // an optional -modfile flag to not use the main go.mod 246 - let gotool = [ 246 + let gotool = { 247 247 if #in.modfile != "" { 248 248 "go tool -modfile=\(#in.modfile)" 249 - }, 250 - "go tool", 251 - ][0] 249 + } else { 250 + "go tool" 251 + } 252 + } 252 253 253 254 // TODO(mvdan): swap "/cache" for "${{ env.NSC_CACHE_PATH }}" once Namespace wires up that env var 254 255 // for the workspace environment. See: https://discord.com/channels/975088590705012777/1397128547797176340 ··· 357 358 // 358 359 // Dispatch-Trailer: {"type:} 359 360 // 360 - let _typeCheck = [if #type != _|_ {#type + "\""}, ""][0] 361 + // TODO(mvdan): using a struct embedding a string here doesn't work. why? 362 + let _typeCheck = [if #type != _|_ {#type + "\""} else {""}][0] 361 363 """ 362 364 (contains(\(_dispatchTrailerVariable), '\n\(dispatchTrailer): {"type":"\(_typeCheck)')) 363 365 """
+4 -5
internal/ci/base/helpers.cue
··· 14 14 _matchPattern: { 15 15 variable: string 16 16 pattern: string 17 - expr: [ 17 + expr: { 18 18 if strings.HasSuffix(pattern, "*") { 19 19 let prefix = strings.TrimSuffix(pattern, "*") 20 20 "startsWith(\(variable), '\(prefix)')" 21 - }, 22 - { 21 + } else { 23 22 "\(variable) == '\(pattern)'" 24 - }, 25 - ][0] 23 + } 24 + } 26 25 } 27 26 28 27 doNotEditMessage: {
+1 -1
internal/ci/cue.mod/module.cue
··· 1 1 module: "github.com/cue-lang/tmp/internal/ci" 2 2 language: { 3 - version: "v0.15.0" 3 + version: "v0.16.0" 4 4 } 5 5 source: { 6 6 kind: "self"