this repo has no description
0
fork

Configure Feed

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

pkg: make $id in tasks a reference to a hidden field

As suggested by Paul and Marcel, hidden fields are unique to a package,
so unlike regular fields like `$id` they cannot be replaced by
a field from a different package or a field from unmarshalled data.

For each of the task definitions, keep `$id` around for backwards
compatibility, but make it a reference to the new `_id`.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I8d1d8ba765f782e2cb9d3f70612c7834fef53fa5
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1214986
Reviewed-by: Paul Jolly <paul@myitcv.io>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>

+186 -145
+1 -1
cmd/cue/cmd/testdata/script/cmd_baddisplay.txtar
··· 5 5 -- cmd_baddisplay.out -- 6 6 command.baddisplay.display.text: conflicting values 42 and string (mismatched types int and string): 7 7 ./task_tool.cue:6:9 8 - tool/cli:4:9 8 + tool/cli:5:9 9 9 -- task.cue -- 10 10 package home 11 11 message: "Hello world!"
+3 -3
cmd/cue/cmd/testdata/script/cmd_err.txtar
··· 5 5 -- cmd_badfields.out -- 6 6 command.ref.task.display.contents: invalid bytes argument: non-concrete value (string|bytes): 7 7 ./task_tool.cue:6:8 8 - tool/file:17:3 8 + tool/file:20:3 9 9 command.ref.task.display.filename: invalid string argument: non-concrete value string: 10 10 ./task_tool.cue:6:8 11 11 ./task_tool.cue:7:9 12 - tool/file:15:3 13 - tool/file:15:16 12 + tool/file:18:3 13 + tool/file:18:16 14 14 -- task_tool.cue -- 15 15 package home 16 16
+3 -3
cmd/cue/cmd/testdata/script/cmd_errpos.txtar
··· 9 9 ./task_tool.cue:9:10 10 10 ./task_tool.cue:12:13 11 11 ./task_tool.cue:17:3 12 - tool/file:11:3 12 + tool/file:13:3 13 13 command.prompter.filename: invalid string argument: non-concrete value string: 14 14 ./task_tool.cue:9:10 15 - tool/file:9:3 16 - tool/file:9:16 15 + tool/file:11:3 16 + tool/file:11:16 17 17 -- task_tool.cue -- 18 18 package foo 19 19
+4 -2
pkg/tool/cli/cli.cue
··· 16 16 17 17 // Print sends text to the stdout of the current process. 18 18 Print: { 19 - $id: *"tool/cli.Print" | "print" // for backwards compatibility 19 + $id: _id 20 + _id: *"tool/cli.Print" | "print" // for backwards compatibility 20 21 21 22 // text is the text to be printed. 22 23 text: string ··· 30 31 // response: bool 31 32 // }) 32 33 Ask: { 33 - $id: "tool/cli.Ask" 34 + $id: _id 35 + _id: "tool/cli.Ask" 34 36 35 37 // prompt sends this message to the output. 36 38 prompt: string
+8 -4
pkg/tool/cli/pkg.go
··· 6 6 // 7 7 // // Print sends text to the stdout of the current process. 8 8 // Print: { 9 - // $id: *"tool/cli.Print" | "print" // for backwards compatibility 9 + // $id: _id 10 + // _id: *"tool/cli.Print" | "print" // for backwards compatibility 10 11 // 11 12 // // text is the text to be printed. 12 13 // text: string ··· 20 21 // // response: bool 21 22 // // }) 22 23 // Ask: { 23 - // $id: "tool/cli.Ask" 24 + // $id: _id 25 + // _id: "tool/cli.Ask" 24 26 // 25 27 // // prompt sends this message to the output. 26 28 // prompt: string ··· 46 48 Native: []*pkg.Builtin{}, 47 49 CUE: `{ 48 50 Print: { 49 - $id: *"tool/cli.Print" | "print" 51 + $id: _id 52 + _id: *"tool/cli.Print" | "print" 50 53 text: string 51 54 } 52 55 Ask: { 53 - $id: "tool/cli.Ask" 56 + $id: _id 57 + _id: "tool/cli.Ask" 54 58 prompt: string 55 59 response: string | bool 56 60 }
+2 -1
pkg/tool/exec/exec.cue
··· 16 16 17 17 // Run executes a program with the given arguments. 18 18 Run: { 19 - $id: *"tool/exec.Run" | "exec" // exec for backwards compatibility 19 + $id: _id 20 + _id: *"tool/exec.Run" | "exec" // exec for backwards compatibility 20 21 21 22 // cmd is a non-empty list holding the program name to run 22 23 // and the arguments to be passed to it.
+4 -2
pkg/tool/exec/pkg.go
··· 6 6 // 7 7 // // Run executes a program with the given arguments. 8 8 // Run: { 9 - // $id: *"tool/exec.Run" | "exec" // exec for backwards compatibility 9 + // $id: _id 10 + // _id: *"tool/exec.Run" | "exec" // exec for backwards compatibility 10 11 // 11 12 // // cmd is a non-empty list holding the program name to run 12 13 // // and the arguments to be passed to it. ··· 64 65 Native: []*pkg.Builtin{}, 65 66 CUE: `{ 66 67 Run: { 67 - $id: *"tool/exec.Run" | "exec" 68 + $id: _id 69 + _id: *"tool/exec.Run" | "exec" 68 70 cmd: string | [string, ...string] 69 71 dir?: string 70 72 env: {[string]: string} | [...=~"="]
+14 -7
pkg/tool/file/file.cue
··· 16 16 17 17 // Read reads the contents of a file. 18 18 Read: { 19 - $id: "tool/file.Read" 19 + $id: _id 20 + _id: "tool/file.Read" 20 21 21 22 // filename names the file to read. 22 23 // ··· 32 33 33 34 // Append writes contents to the given file. 34 35 Append: { 35 - $id: "tool/file.Append" 36 + $id: _id 37 + _id: "tool/file.Append" 36 38 37 39 // filename names the file to append. 38 40 // ··· 49 51 50 52 // Create writes contents to the given file. 51 53 Create: { 52 - $id: "tool/file.Create" 54 + $id: _id 55 + _id: "tool/file.Create" 53 56 54 57 // filename names the file to write. 55 58 // ··· 66 69 67 70 // Glob returns a list of files. 68 71 Glob: { 69 - $id: "tool/file.Glob" 72 + $id: _id 73 + _id: "tool/file.Glob" 70 74 71 75 // glob specifies the pattern to match files with. 72 76 // ··· 78 82 79 83 // Mkdir creates a directory at the specified path. 80 84 Mkdir: { 81 - $id: "tool/file.Mkdir" 85 + $id: _id 86 + _id: "tool/file.Mkdir" 82 87 83 88 // The directory path to create. 84 89 // If path is already a directory, Mkdir does nothing. ··· 105 110 // It is the caller's responsibility to remove the directory when it is no 106 111 // longer needed. 107 112 MkdirTemp: { 108 - $id: "tool/file.MkdirTemp" 113 + $id: _id 114 + _id: "tool/file.MkdirTemp" 109 115 110 116 // The temporary directory is created in the directory specified by dir. 111 117 // If dir is the empty string, MkdirTemp uses the default directory for ··· 123 129 // RemoveAll removes path and any children it contains. 124 130 // It removes everything it can but returns the first error it encounters. 125 131 RemoveAll: { 126 - $id: "tool/file.RemoveAll" 132 + $id: _id 133 + _id: "tool/file.RemoveAll" 127 134 128 135 // The path to remove. 129 136 // If the path does not exist, RemoveAll does nothing.
+28 -14
pkg/tool/file/pkg.go
··· 6 6 // 7 7 // // Read reads the contents of a file. 8 8 // Read: { 9 - // $id: "tool/file.Read" 9 + // $id: _id 10 + // _id: "tool/file.Read" 10 11 // 11 12 // // filename names the file to read. 12 13 // // ··· 22 23 // 23 24 // // Append writes contents to the given file. 24 25 // Append: { 25 - // $id: "tool/file.Append" 26 + // $id: _id 27 + // _id: "tool/file.Append" 26 28 // 27 29 // // filename names the file to append. 28 30 // // ··· 39 41 // 40 42 // // Create writes contents to the given file. 41 43 // Create: { 42 - // $id: "tool/file.Create" 44 + // $id: _id 45 + // _id: "tool/file.Create" 43 46 // 44 47 // // filename names the file to write. 45 48 // // ··· 56 59 // 57 60 // // Glob returns a list of files. 58 61 // Glob: { 59 - // $id: "tool/file.Glob" 62 + // $id: _id 63 + // _id: "tool/file.Glob" 60 64 // 61 65 // // glob specifies the pattern to match files with. 62 66 // // ··· 68 72 // 69 73 // // Mkdir creates a directory at the specified path. 70 74 // Mkdir: { 71 - // $id: "tool/file.Mkdir" 75 + // $id: _id 76 + // _id: "tool/file.Mkdir" 72 77 // 73 78 // // The directory path to create. 74 79 // // If path is already a directory, Mkdir does nothing. ··· 95 100 // // It is the caller's responsibility to remove the directory when it is no 96 101 // // longer needed. 97 102 // MkdirTemp: { 98 - // $id: "tool/file.MkdirTemp" 103 + // $id: _id 104 + // _id: "tool/file.MkdirTemp" 99 105 // 100 106 // // The temporary directory is created in the directory specified by dir. 101 107 // // If dir is the empty string, MkdirTemp uses the default directory for ··· 113 119 // // RemoveAll removes path and any children it contains. 114 120 // // It removes everything it can but returns the first error it encounters. 115 121 // RemoveAll: { 116 - // $id: "tool/file.RemoveAll" 122 + // $id: _id 123 + // _id: "tool/file.RemoveAll" 117 124 // 118 125 // // The path to remove. 119 126 // // If the path does not exist, RemoveAll does nothing. ··· 141 148 Native: []*pkg.Builtin{}, 142 149 CUE: `{ 143 150 Read: { 144 - $id: "tool/file.Read" 151 + $id: _id 152 + _id: "tool/file.Read" 145 153 filename: !="" 146 154 contents: *bytes | string 147 155 } 148 156 Append: { 149 - $id: "tool/file.Append" 157 + $id: _id 158 + _id: "tool/file.Append" 150 159 filename: !="" 151 160 permissions: int | *0o666 152 161 contents: bytes | string 153 162 } 154 163 Create: { 155 - $id: "tool/file.Create" 164 + $id: _id 165 + _id: "tool/file.Create" 156 166 filename: !="" 157 167 permissions: int | *0o666 158 168 contents: bytes | string 159 169 } 160 170 Glob: { 161 - $id: "tool/file.Glob" 171 + $id: _id 172 + _id: "tool/file.Glob" 162 173 glob: !="" 163 174 files: [...string] 164 175 } 165 176 Mkdir: { 166 - $id: "tool/file.Mkdir" 177 + $id: _id 178 + _id: "tool/file.Mkdir" 167 179 path: string 168 180 createParents: bool | *false 169 181 permissions: int | *0o777 ··· 172 184 createParents: true 173 185 } 174 186 MkdirTemp: { 175 - $id: "tool/file.MkdirTemp" 187 + $id: _id 188 + _id: "tool/file.MkdirTemp" 176 189 dir: string | *"" 177 190 pattern: string | *"" 178 191 path: string 179 192 } 180 193 RemoveAll: { 181 - $id: "tool/file.RemoveAll" 194 + $id: _id 195 + _id: "tool/file.RemoveAll" 182 196 path: string 183 197 success: bool 184 198 }
+2 -1
pkg/tool/http/http.cue
··· 20 20 Delete: Do & {method: "DELETE"} 21 21 22 22 Do: { 23 - $id: *"tool/http.Do" | "http" // http for backwards compatibility 23 + $id: _id 24 + _id: *"tool/http.Do" | "http" // http for backwards compatibility 24 25 25 26 method: string 26 27 url: string // TODO: make url.URL type
+4 -2
pkg/tool/http/pkg.go
··· 10 10 // Delete: Do & {method: "DELETE"} 11 11 // 12 12 // Do: { 13 - // $id: *"tool/http.Do" | "http" // http for backwards compatibility 13 + // $id: _id 14 + // _id: *"tool/http.Do" | "http" // http for backwards compatibility 14 15 // 15 16 // method: string 16 17 // url: string // TODO: make url.URL type ··· 74 75 Put: Do & {method: "PUT"} 75 76 Delete: Do & {method: "DELETE"} 76 77 Do: { 77 - $id: *"tool/http.Do" | "http" 78 + $id: _id 79 + _id: *"tool/http.Do" | "http" 78 80 method: string 79 81 url: string 80 82 followRedirects: *true | bool
+8 -4
pkg/tool/os/os.cue
··· 27 27 // To define a shorthand, define the shorthand as a new flag referring to 28 28 // the flag of which it is a shorthand. 29 29 Setenv: { 30 - $id: "tool/os.Setenv" 30 + $id: _id 31 + _id: "tool/os.Setenv" 31 32 32 33 {[Name]: Value} 33 34 } 34 35 35 36 // Getenv gets and parses the specific command line variables. 36 37 Getenv: { 37 - $id: "tool/os.Getenv" 38 + $id: _id 39 + _id: "tool/os.Getenv" 38 40 39 41 {[Name]: Value} 40 42 } 41 43 42 44 // Environ populates a struct with all environment variables. 43 45 Environ: { 44 - $id: "tool/os.Environ" 46 + $id: _id 47 + _id: "tool/os.Environ" 45 48 46 49 // A map of all populated values. 47 50 // Individual entries may be specified ahead of time to enable ··· 52 55 53 56 // Clearenv clears all environment variables. 54 57 Clearenv: { 55 - $id: "tool/os.Clearenv" 58 + $id: _id 59 + _id: "tool/os.Clearenv" 56 60 }
+16 -8
pkg/tool/os/pkg.go
··· 17 17 // // To define a shorthand, define the shorthand as a new flag referring to 18 18 // // the flag of which it is a shorthand. 19 19 // Setenv: { 20 - // $id: "tool/os.Setenv" 20 + // $id: _id 21 + // _id: "tool/os.Setenv" 21 22 // 22 23 // {[Name]: Value} 23 24 // } 24 25 // 25 26 // // Getenv gets and parses the specific command line variables. 26 27 // Getenv: { 27 - // $id: "tool/os.Getenv" 28 + // $id: _id 29 + // _id: "tool/os.Getenv" 28 30 // 29 31 // {[Name]: Value} 30 32 // } 31 33 // 32 34 // // Environ populates a struct with all environment variables. 33 35 // Environ: { 34 - // $id: "tool/os.Environ" 36 + // $id: _id 37 + // _id: "tool/os.Environ" 35 38 // 36 39 // // A map of all populated values. 37 40 // // Individual entries may be specified ahead of time to enable ··· 42 45 // 43 46 // // Clearenv clears all environment variables. 44 47 // Clearenv: { 45 - // $id: "tool/os.Clearenv" 48 + // $id: _id 49 + // _id: "tool/os.Clearenv" 46 50 // } 47 51 package os 48 52 ··· 63 67 Value: bool | number | *string | null 64 68 Name: !="" & !~"^[$]" 65 69 Setenv: { 66 - $id: "tool/os.Setenv" 70 + $id: _id 71 + _id: "tool/os.Setenv" 67 72 {[Name]: Value} 68 73 } 69 74 Getenv: { 70 - $id: "tool/os.Getenv" 75 + $id: _id 76 + _id: "tool/os.Getenv" 71 77 {[Name]: Value} 72 78 } 73 79 Environ: { 74 - $id: "tool/os.Environ" 80 + $id: _id 81 + _id: "tool/os.Environ" 75 82 {[Name]: Value} 76 83 } 77 84 Clearenv: { 78 - $id: "tool/os.Clearenv" 85 + $id: _id 86 + _id: "tool/os.Clearenv" 79 87 } 80 88 }`, 81 89 }
-2
pkg/tool/pkg.go
··· 69 69 // 70 70 // // A Task defines a step in the execution of a command. 71 71 // Task: { 72 - // $type: "tool.Task" // legacy field 'kind' still supported for now. 73 - // 74 72 // // $id indicates the operation to run. It must be of the form 75 73 // // packagePath.Operation. 76 74 // $id: =~#"\."#
-2
pkg/tool/tool.cue
··· 64 64 65 65 // A Task defines a step in the execution of a command. 66 66 Task: { 67 - $type: "tool.Task" // legacy field 'kind' still supported for now. 68 - 69 67 // $id indicates the operation to run. It must be of the form 70 68 // packagePath.Operation. 71 69 $id: =~#"\."#
+12 -12
tools/flow/testdata/issue2397.txtar
··· 35 35 } 36 36 -- out/run/t1/stats -- 37 37 Leaks: 0 38 - Freed: 11 39 - Reused: 5 40 - Allocs: 6 38 + Freed: 14 39 + Reused: 7 40 + Allocs: 7 41 41 Retain: 1 42 42 43 - Unifications: 9 44 - Conjuncts: 25 45 - Disjuncts: 12 43 + Unifications: 10 44 + Conjuncts: 29 45 + Disjuncts: 15 46 46 -- out/run/stats/totals -- 47 47 Leaks: 0 48 - Freed: 11 49 - Reused: 5 50 - Allocs: 6 48 + Freed: 14 49 + Reused: 7 50 + Allocs: 7 51 51 Retain: 1 52 52 53 - Unifications: 9 54 - Conjuncts: 25 55 - Disjuncts: 12 53 + Unifications: 10 54 + Conjuncts: 29 55 + Disjuncts: 15
+18 -18
tools/flow/testdata/issue2416a.txtar
··· 79 79 } 80 80 -- out/run/t1/stats -- 81 81 Leaks: 0 82 - Freed: 54 83 - Reused: 45 82 + Freed: 57 83 + Reused: 48 84 84 Allocs: 9 85 - Retain: 2 85 + Retain: 5 86 86 87 - Unifications: 38 88 - Conjuncts: 98 89 - Disjuncts: 56 87 + Unifications: 41 88 + Conjuncts: 101 89 + Disjuncts: 59 90 90 -- out/run/t2 -- 91 91 graph TD 92 92 t0("root.build.task.mkdir.output [Terminated]") ··· 113 113 } 114 114 -- out/run/t2/stats -- 115 115 Leaks: 0 116 - Freed: 55 117 - Reused: 55 116 + Freed: 58 117 + Reused: 58 118 118 Allocs: 0 119 - Retain: 2 119 + Retain: 5 120 120 121 - Unifications: 39 122 - Conjuncts: 105 123 - Disjuncts: 57 121 + Unifications: 42 122 + Conjuncts: 108 123 + Disjuncts: 60 124 124 -- out/run/stats/totals -- 125 125 Leaks: 0 126 - Freed: 109 127 - Reused: 100 126 + Freed: 115 127 + Reused: 106 128 128 Allocs: 9 129 - Retain: 4 129 + Retain: 10 130 130 131 - Unifications: 77 132 - Conjuncts: 203 133 - Disjuncts: 113 131 + Unifications: 83 132 + Conjuncts: 209 133 + Disjuncts: 119
+12 -12
tools/flow/testdata/issue2416b.txtar
··· 44 44 } 45 45 -- out/run/t1/stats -- 46 46 Leaks: 0 47 - Freed: 30 48 - Reused: 24 49 - Allocs: 6 47 + Freed: 33 48 + Reused: 26 49 + Allocs: 7 50 50 Retain: 1 51 51 52 - Unifications: 22 53 - Conjuncts: 57 54 - Disjuncts: 31 52 + Unifications: 23 53 + Conjuncts: 61 54 + Disjuncts: 34 55 55 -- out/run/stats/totals -- 56 56 Leaks: 0 57 - Freed: 30 58 - Reused: 24 59 - Allocs: 6 57 + Freed: 33 58 + Reused: 26 59 + Allocs: 7 60 60 Retain: 1 61 61 62 - Unifications: 22 63 - Conjuncts: 57 64 - Disjuncts: 31 62 + Unifications: 23 63 + Conjuncts: 61 64 + Disjuncts: 34
+12 -12
tools/flow/testdata/issue2490.txtar
··· 31 31 } 32 32 -- out/run/t1/stats -- 33 33 Leaks: 0 34 - Freed: 9 35 - Reused: 3 36 - Allocs: 6 34 + Freed: 12 35 + Reused: 5 36 + Allocs: 7 37 37 Retain: 0 38 38 39 - Unifications: 7 40 - Conjuncts: 17 41 - Disjuncts: 9 39 + Unifications: 8 40 + Conjuncts: 21 41 + Disjuncts: 12 42 42 -- out/run/stats/totals -- 43 43 Leaks: 0 44 - Freed: 9 45 - Reused: 3 46 - Allocs: 6 44 + Freed: 12 45 + Reused: 5 46 + Allocs: 7 47 47 Retain: 0 48 48 49 - Unifications: 7 50 - Conjuncts: 17 51 - Disjuncts: 9 49 + Unifications: 8 50 + Conjuncts: 21 51 + Disjuncts: 12
+10 -10
tools/flow/testdata/issue2559.txtar
··· 60 60 } 61 61 -- out/run/t1/stats -- 62 62 Leaks: 35 63 - Freed: 25539 64 - Reused: 25523 63 + Freed: 25542 64 + Reused: 25526 65 65 Allocs: 51 66 66 Retain: 337 67 67 68 - Unifications: 18344 69 - Conjuncts: 76391 70 - Disjuncts: 25823 68 + Unifications: 18345 69 + Conjuncts: 76395 70 + Disjuncts: 25826 71 71 -- out/run/stats/totals -- 72 72 Leaks: 35 73 - Freed: 25539 74 - Reused: 25523 73 + Freed: 25542 74 + Reused: 25526 75 75 Allocs: 51 76 76 Retain: 337 77 77 78 - Unifications: 18344 79 - Conjuncts: 76391 80 - Disjuncts: 25823 78 + Unifications: 18345 79 + Conjuncts: 76395 80 + Disjuncts: 25826 81 81 -- out/run/t2 -- 82 82 graph TD 83 83 t0("root.prepare [Terminated]")
+10 -10
tools/flow/testdata/statsfail.txtar
··· 27 27 } 28 28 -- out/run/t1/stats -- 29 29 Leaks: 8 30 - Freed: 20 31 - Reused: 16 30 + Freed: 23 31 + Reused: 19 32 32 Allocs: 12 33 33 Retain: 24 34 34 35 - Unifications: 26 36 - Conjuncts: 34 37 - Disjuncts: 38 35 + Unifications: 27 36 + Conjuncts: 38 37 + Disjuncts: 41 38 38 -- out/run/stats/totals -- 39 39 Leaks: 8 40 - Freed: 20 41 - Reused: 16 40 + Freed: 23 41 + Reused: 19 42 42 Allocs: 12 43 43 Retain: 24 44 44 45 - Unifications: 26 46 - Conjuncts: 34 47 - Disjuncts: 38 45 + Unifications: 27 46 + Conjuncts: 38 47 + Disjuncts: 41 48 48 -- out/run/t2 -- 49 49 graph TD 50 50 t0("root.prepare [Terminated]")
+15 -15
tools/flow/testdata/template.txtar
··· 48 48 } 49 49 -- out/run/t1/stats -- 50 50 Leaks: 0 51 - Freed: 47 52 - Reused: 40 51 + Freed: 50 52 + Reused: 43 53 53 Allocs: 7 54 54 Retain: 0 55 55 56 - Unifications: 26 57 - Conjuncts: 71 58 - Disjuncts: 47 56 + Unifications: 27 57 + Conjuncts: 75 58 + Disjuncts: 50 59 59 -- out/run/t2 -- 60 60 graph TD 61 61 t0("root.get [Terminated]") ··· 91 91 } 92 92 -- out/run/t2/stats -- 93 93 Leaks: 0 94 - Freed: 47 95 - Reused: 47 94 + Freed: 50 95 + Reused: 50 96 96 Allocs: 0 97 97 Retain: 0 98 98 99 - Unifications: 26 100 - Conjuncts: 76 101 - Disjuncts: 47 99 + Unifications: 27 100 + Conjuncts: 80 101 + Disjuncts: 50 102 102 -- out/run/stats/totals -- 103 103 Leaks: 0 104 - Freed: 94 105 - Reused: 87 104 + Freed: 100 105 + Reused: 93 106 106 Allocs: 7 107 107 Retain: 0 108 108 109 - Unifications: 52 110 - Conjuncts: 147 111 - Disjuncts: 94 109 + Unifications: 54 110 + Conjuncts: 155 111 + Disjuncts: 100 112 112 -- out/run/t3 -- 113 113 graph TD 114 114 t0("root.get [Terminated]")