Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package yq for openSUSE:Factory checked in at 2023-01-16 17:59:44 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yq (Old) and /work/SRC/openSUSE:Factory/.yq.new.32243 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yq" Mon Jan 16 17:59:44 2023 rev:5 rq:1058658 version:4.30.8 Changes: -------- --- /work/SRC/openSUSE:Factory/yq/yq.changes 2022-12-18 19:11:48.553987842 +0100 +++ /work/SRC/openSUSE:Factory/.yq.new.32243/yq.changes 2023-01-16 18:02:21.747976983 +0100 @@ -1,0 +2,12 @@ +Mon Jan 16 09:05:04 UTC 2023 - Dirk Müller <dmuel...@suse.com> + +- update to v4.30.8: + * Log info message instead of erroring when unable to chown file in linux + (e.g. snap confinement) #1521 + * Fixed bug in splice operator #1511 + * Fixed value operator bug #1515 + * Fixed handling of merging null #1501 + * Ownership of file now maintained in linux (thanks @vaguecoder) #1473 + * Bumped dependency versions + +------------------------------------------------------------------- Old: ---- _servicedata yq-4.30.6.tar.gz New: ---- yq-4.30.8.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yq.spec ++++++ --- /var/tmp/diff_new_pack.plGSax/_old 2023-01-16 18:02:22.295979907 +0100 +++ /var/tmp/diff_new_pack.plGSax/_new 2023-01-16 18:02:22.299979929 +0100 @@ -1,7 +1,7 @@ # # spec file for package yq # -# Copyright (c) 2022 SUSE LLC +# Copyright (c) 2023 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -20,12 +20,12 @@ %global import_path %{provider_prefix} Name: yq -Version: 4.30.6 +Version: 4.30.8 Release: 0 Summary: A portable command-line YAML processor License: MIT URL: https://github.com/mikefarah/yq -Source0: https://github.com/mikefarah/yq/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz +Source0: https://github.com/mikefarah/yq/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz Source1: vendor.tar.gz # conflict with all python3X-yq packages since they install /usr/bin/yq # we need to handle Leap 15.4 specially since the python3dist() is not ++++++ _service ++++++ --- /var/tmp/diff_new_pack.plGSax/_old 2023-01-16 18:02:22.323980057 +0100 +++ /var/tmp/diff_new_pack.plGSax/_new 2023-01-16 18:02:22.327980078 +0100 @@ -1,20 +1,5 @@ <services> - <service name="tar_scm" mode="disabled"> - <param name="url">https://github.com/mikefarah/yq.git</param> - <param name="scm">git</param> - <param name="exclude">.git</param> - <param name="versionformat">@PARENT_TAG@</param> - <param name="versionrewrite-pattern">v(.*)</param> - <param name="revision">v4.30.6</param> - <param name="changesgenerate">enable</param> - </service> - <service name="recompress" mode="disabled"> - <param name="file">yq-*.tar</param> - <param name="compression">gz</param> - </service> - <service name="set_version" mode="disabled"> - <param name="basename">yq</param> - </service> + <service name="download_files" mode="disabled"/> <service name="go_modules" mode="disabled"/> </services> ++++++ vendor.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/github.com/alecthomas/repr/repr.go new/vendor/github.com/alecthomas/repr/repr.go --- old/vendor/github.com/alecthomas/repr/repr.go 2022-12-18 14:43:21.000000000 +0100 +++ new/vendor/github.com/alecthomas/repr/repr.go 2023-01-16 10:04:24.000000000 +0100 @@ -12,6 +12,7 @@ "os" "reflect" "sort" + "strings" "time" "unsafe" ) @@ -44,6 +45,7 @@ } goStringerType = reflect.TypeOf((*fmt.GoStringer)(nil)).Elem() + anyType = reflect.TypeOf((*any)(nil)).Elem() byteSliceType = reflect.TypeOf([]byte{}) ) @@ -70,7 +72,7 @@ func IgnoreGoStringer() Option { return func(o *Printer) { o.ignoreGoStringer = true } } // Hide excludes the given types from representation, instead just printing the name of the type. -func Hide(ts ...interface{}) Option { +func Hide(ts ...any) Option { return func(o *Printer) { for _, t := range ts { rt := reflect.Indirect(reflect.ValueOf(t)).Type() @@ -122,27 +124,28 @@ } // Print the values. -func (p *Printer) Print(vs ...interface{}) { +func (p *Printer) Print(vs ...any) { for i, v := range vs { if i > 0 { fmt.Fprint(p.w, " ") } - p.reprValue(map[reflect.Value]bool{}, reflect.ValueOf(v), "", true) + p.reprValue(map[reflect.Value]bool{}, reflect.ValueOf(v), "", true, false) } } // Println prints each value on a new line. -func (p *Printer) Println(vs ...interface{}) { +func (p *Printer) Println(vs ...any) { for i, v := range vs { if i > 0 { fmt.Fprint(p.w, " ") } - p.reprValue(map[reflect.Value]bool{}, reflect.ValueOf(v), "", true) + p.reprValue(map[reflect.Value]bool{}, reflect.ValueOf(v), "", true, false) } fmt.Fprintln(p.w) } -func (p *Printer) reprValue(seen map[reflect.Value]bool, v reflect.Value, indent string, showType bool) { // nolint: gocyclo +// showType is true if struct types should be shown. isAnyValue is true if the containing value is an "any" type. +func (p *Printer) reprValue(seen map[reflect.Value]bool, v reflect.Value, indent string, showStructType bool, isAnyValue bool) { // nolint: gocyclo if seen[v] { fmt.Fprint(p.w, "...") return @@ -181,7 +184,7 @@ ni := p.nextIndent(indent) switch v.Kind() { case reflect.Slice, reflect.Array: - fmt.Fprintf(p.w, "%s{", v.Type()) + fmt.Fprintf(p.w, "%s{", substAny(v.Type())) if v.Len() == 0 { fmt.Fprint(p.w, "}") } else { @@ -191,7 +194,7 @@ for i := 0; i < v.Len(); i++ { e := v.Index(i) fmt.Fprintf(p.w, "%s", ni) - p.reprValue(seen, e, ni, p.alwaysIncludeType || p.explicitTypes) + p.reprValue(seen, e, ni, p.alwaysIncludeType || p.explicitTypes, v.Type().Elem() == anyType) if p.indent != "" { fmt.Fprintf(p.w, ",\n") } else if i < v.Len()-1 { @@ -203,11 +206,11 @@ case reflect.Chan: fmt.Fprintf(p.w, "make(") - fmt.Fprintf(p.w, "%s", v.Type()) + fmt.Fprintf(p.w, "%s", substAny(v.Type())) fmt.Fprintf(p.w, ", %d)", v.Cap()) case reflect.Map: - fmt.Fprintf(p.w, "%s{", v.Type()) + fmt.Fprintf(p.w, "%s{", substAny(v.Type())) if p.indent != "" && v.Len() != 0 { fmt.Fprintf(p.w, "\n") } @@ -218,9 +221,9 @@ for i, k := range keys { kv := v.MapIndex(k) fmt.Fprintf(p.w, "%s", ni) - p.reprValue(seen, k, ni, p.alwaysIncludeType || p.explicitTypes) + p.reprValue(seen, k, ni, p.alwaysIncludeType || p.explicitTypes, v.Type().Key() == anyType) fmt.Fprintf(p.w, ": ") - p.reprValue(seen, kv, ni, true) + p.reprValue(seen, kv, ni, true, v.Type().Elem() == anyType) if p.indent != "" { fmt.Fprintf(p.w, ",\n") } else if i < v.Len()-1 { @@ -233,8 +236,8 @@ if td, ok := asTime(v); ok { timeToGo(p.w, td) } else { - if showType { - fmt.Fprintf(p.w, "%s{", v.Type()) + if showStructType { + fmt.Fprintf(p.w, "%s{", substAny(v.Type())) } else { fmt.Fprint(p.w, "{") } @@ -248,7 +251,7 @@ continue } fmt.Fprintf(p.w, "%s%s: ", ni, t.Name) - p.reprValue(seen, f, ni, true) + p.reprValue(seen, f, ni, true, t.Type == anyType) if p.indent != "" { fmt.Fprintf(p.w, ",\n") } else if i < v.NumField()-1 { @@ -262,10 +265,10 @@ fmt.Fprintf(p.w, "nil") return } - if showType { + if showStructType { fmt.Fprintf(p.w, "&") } - p.reprValue(seen, v.Elem(), indent, showType) + p.reprValue(seen, v.Elem(), indent, showStructType, false) case reflect.String: if t.Name() != "string" || p.alwaysIncludeType { @@ -276,13 +279,16 @@ case reflect.Interface: if v.IsNil() { - fmt.Fprintf(p.w, "interface {}(nil)") + fmt.Fprintf(p.w, "%s(nil)", substAny(v.Type())) } else { - p.reprValue(seen, v.Elem(), indent, true) + p.reprValue(seen, v.Elem(), indent, true, true) } + case reflect.Func: + fmt.Fprint(p.w, substAny(v.Type())) + default: - if t.Name() != realKindName[t.Kind()] || p.alwaysIncludeType { + if t.Name() != realKindName[t.Kind()] || p.alwaysIncludeType || isAnyValue { fmt.Fprintf(p.w, "%s(%v)", t, v) } else { fmt.Fprintf(p.w, "%v", v) @@ -299,7 +305,7 @@ } // String returns a string representing v. -func String(v interface{}, options ...Option) string { +func String(v any, options ...Option) string { w := bytes.NewBuffer(nil) options = append([]Option{NoIndent()}, options...) p := New(w, options...) @@ -307,7 +313,7 @@ return w.String() } -func extractOptions(vs ...interface{}) (args []interface{}, options []Option) { +func extractOptions(vs ...any) (args []any, options []Option) { for _, v := range vs { if o, ok := v.(Option); ok { options = append(options, o) @@ -319,13 +325,13 @@ } // Println prints v to os.Stdout, one per line. -func Println(vs ...interface{}) { +func Println(vs ...any) { args, options := extractOptions(vs...) New(os.Stdout, options...).Println(args...) } // Print writes a representation of v to os.Stdout, separated by spaces. -func Print(vs ...interface{}) { +func Print(vs ...any) { args, options := extractOptions(vs...) New(os.Stdout, options...).Print(args...) } @@ -351,3 +357,39 @@ y, m, d := t.Date() fmt.Fprintf(w, `time.Date(%d, %d, %d, %d, %d, %d, %d, %s)`, y, m, d, t.Hour(), t.Minute(), t.Second(), t.Nanosecond(), zone) } + +// Replace "interface {}" with "any" +func substAny(t reflect.Type) string { + switch t.Kind() { + case reflect.Array: + return fmt.Sprintf("[%d]%s", t.Len(), substAny(t.Elem())) + + case reflect.Slice: + return "[]" + substAny(t.Elem()) + + case reflect.Map: + return "map[" + substAny(t.Key()) + "]" + substAny(t.Elem()) + + case reflect.Chan: + return fmt.Sprintf("%s %s", t.ChanDir(), substAny(t.Elem())) + + case reflect.Func: + in := []string{} + out := []string{} + for i := 0; i < t.NumIn(); i++ { + in = append(in, substAny(t.In(i))) + } + for i := 0; i < t.NumOut(); i++ { + out = append(out, substAny(t.Out(i))) + } + if len(out) == 0 { + return "func" + t.Name() + "(" + strings.Join(in, ", ") + ")" + } + return "func" + t.Name() + "(" + strings.Join(in, ", ") + ") (" + strings.Join(out, ", ") + ")" + } + + if t == anyType { + return "any" + } + return t.String() +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/github.com/goccy/go-yaml/ast/ast.go new/vendor/github.com/goccy/go-yaml/ast/ast.go --- old/vendor/github.com/goccy/go-yaml/ast/ast.go 2022-12-18 14:43:21.000000000 +0100 +++ new/vendor/github.com/goccy/go-yaml/ast/ast.go 2023-01-16 10:04:24.000000000 +0100 @@ -566,7 +566,11 @@ for _, doc := range f.Docs { docs = append(docs, doc.String()) } - return strings.Join(docs, "\n") + if len(docs) > 0 { + return strings.Join(docs, "\n") + "\n" + } else { + return "" + } } // DocumentNode type of Document diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/github.com/goccy/go-yaml/scanner/scanner.go new/vendor/github.com/goccy/go-yaml/scanner/scanner.go --- old/vendor/github.com/goccy/go-yaml/scanner/scanner.go 2022-12-18 14:43:21.000000000 +0100 +++ new/vendor/github.com/goccy/go-yaml/scanner/scanner.go 2023-01-16 10:04:24.000000000 +0100 @@ -61,13 +61,25 @@ s.savedPos = nil return tk } - size := len(ctx.buf) + line := s.line + column := s.column - len(ctx.buf) + level := s.indentLevel + if ctx.isSaveIndentMode() { + line -= s.newLineCount(ctx.buf) + column = strings.Index(string(ctx.obuf), string(ctx.buf)) + 1 + // Since we are in a literal, folded or raw folded + // we can use the indent level from the last token. + last := ctx.lastToken() + if last != nil { // The last token should never be nil here. + level = last.Position.IndentLevel + 1 + } + } return ctx.bufferedToken(&token.Position{ - Line: s.line, - Column: s.column - size, - Offset: s.offset - size, + Line: line, + Column: column, + Offset: s.offset - len(ctx.buf), IndentNum: s.indentNum, - IndentLevel: s.indentLevel, + IndentLevel: level, }) } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/modules.txt new/vendor/modules.txt --- old/vendor/modules.txt 2022-12-18 14:43:21.000000000 +0100 +++ new/vendor/modules.txt 2023-01-16 10:04:24.000000000 +0100 @@ -4,7 +4,7 @@ # github.com/alecthomas/participle/v2 v2.0.0-beta.5 ## explicit; go 1.18 github.com/alecthomas/participle/v2/lexer -# github.com/alecthomas/repr v0.1.1 +# github.com/alecthomas/repr v0.2.0 ## explicit; go 1.18 github.com/alecthomas/repr # github.com/dimchansky/utfbom v1.1.1 @@ -27,7 +27,7 @@ github.com/goccy/go-json/internal/encoder/vm_indent github.com/goccy/go-json/internal/errors github.com/goccy/go-json/internal/runtime -# github.com/goccy/go-yaml v1.9.7 +# github.com/goccy/go-yaml v1.9.8 ## explicit; go 1.12 github.com/goccy/go-yaml/ast github.com/goccy/go-yaml/lexer ++++++ yq-4.30.6.tar.gz -> yq-4.30.8.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-4.30.6/Dockerfile new/yq-4.30.8/Dockerfile --- old/yq-4.30.6/Dockerfile 2022-12-17 01:16:38.000000000 +0100 +++ new/yq-4.30.8/Dockerfile 2023-01-15 01:37:07.000000000 +0100 @@ -1,4 +1,4 @@ -FROM golang:1.19.4 as builder +FROM golang:1.19.5 as builder WORKDIR /go/src/mikefarah/yq diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-4.30.6/Dockerfile.dev new/yq-4.30.8/Dockerfile.dev --- old/yq-4.30.6/Dockerfile.dev 2022-12-17 01:16:38.000000000 +0100 +++ new/yq-4.30.8/Dockerfile.dev 2023-01-15 01:37:07.000000000 +0100 @@ -1,4 +1,4 @@ -FROM golang:1.19.4 +FROM golang:1.19.5 COPY scripts/devtools.sh /opt/devtools.sh diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-4.30.6/cmd/version.go new/yq-4.30.8/cmd/version.go --- old/yq-4.30.6/cmd/version.go 2022-12-17 01:16:38.000000000 +0100 +++ new/yq-4.30.8/cmd/version.go 2023-01-15 01:37:07.000000000 +0100 @@ -11,7 +11,7 @@ GitDescribe string // Version is main version number that is being run at the moment. - Version = "v4.30.6" + Version = "v4.30.8" // VersionPrerelease is a pre-release marker for the version. If this is "" (empty string) // then it means that it is a final release. Otherwise, this is a pre-release diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-4.30.6/go.mod new/yq-4.30.8/go.mod --- old/yq-4.30.6/go.mod 2022-12-17 01:16:38.000000000 +0100 +++ new/yq-4.30.8/go.mod 2023-01-15 01:37:07.000000000 +0100 @@ -3,12 +3,12 @@ require ( github.com/a8m/envsubst v1.3.0 github.com/alecthomas/participle/v2 v2.0.0-beta.5 - github.com/alecthomas/repr v0.1.1 + github.com/alecthomas/repr v0.2.0 github.com/dimchansky/utfbom v1.1.1 github.com/elliotchance/orderedmap v1.5.0 github.com/fatih/color v1.13.0 github.com/goccy/go-json v0.10.0 - github.com/goccy/go-yaml v1.9.7 + github.com/goccy/go-yaml v1.9.8 github.com/jinzhu/copier v0.3.5 github.com/magiconair/properties v1.8.7 github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-4.30.6/go.sum new/yq-4.30.8/go.sum --- old/yq-4.30.6/go.sum 2022-12-17 01:16:38.000000000 +0100 +++ new/yq-4.30.8/go.sum 2023-01-15 01:37:07.000000000 +0100 @@ -3,8 +3,8 @@ github.com/alecthomas/assert/v2 v2.0.3 h1:WKqJODfOiQG0nEJKFKzDIG3E29CN2/4zR9XGJzKIkbg= github.com/alecthomas/participle/v2 v2.0.0-beta.5 h1:y6dsSYVb1G5eK6mgmy+BgI3Mw35a3WghArZ/Hbebrjo= github.com/alecthomas/participle/v2 v2.0.0-beta.5/go.mod h1:RC764t6n4L8D8ITAJv0qdokritYSNR3wV5cVwmIEaMM= -github.com/alecthomas/repr v0.1.1 h1:87P60cSmareLAxMc4Hro0r2RBY4ROm0dYwkJNpS4pPs= -github.com/alecthomas/repr v0.1.1/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= +github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk= +github.com/alecthomas/repr v0.2.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -21,8 +21,8 @@ github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= github.com/goccy/go-json v0.10.0 h1:mXKd9Qw4NuzShiRlOXKews24ufknHO7gx30lsDyokKA= github.com/goccy/go-json v0.10.0/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= -github.com/goccy/go-yaml v1.9.7 h1:D/Vx+JITklB1ugSkncB4BNR67M3X6AKs9+rqVeo3ddw= -github.com/goccy/go-yaml v1.9.7/go.mod h1:JubOolP3gh0HpiBc4BLRD4YmjEjHAmIIB2aaXKkTfoE= +github.com/goccy/go-yaml v1.9.8 h1:5gMyLUeU1/6zl+WFfR1hN7D2kf+1/eRGa7DFtToiBvQ= +github.com/goccy/go-yaml v1.9.8/go.mod h1:JubOolP3gh0HpiBc4BLRD4YmjEjHAmIIB2aaXKkTfoE= github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc= github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-4.30.6/pkg/yqlib/chown_linux.go new/yq-4.30.8/pkg/yqlib/chown_linux.go --- old/yq-4.30.6/pkg/yqlib/chown_linux.go 1970-01-01 01:00:00.000000000 +0100 +++ new/yq-4.30.8/pkg/yqlib/chown_linux.go 2023-01-15 01:37:07.000000000 +0100 @@ -0,0 +1,25 @@ +//go:build linux + +package yqlib + +import ( + "io/fs" + "os" + "syscall" +) + +func changeOwner(info fs.FileInfo, file *os.File) error { + if stat, ok := info.Sys().(*syscall.Stat_t); ok { + uid := int(stat.Uid) + gid := int(stat.Gid) + + err := os.Chown(file.Name(), uid, gid) + if err != nil { + // this happens with snap confinement + // not really a big issue as users can chown + // the file themselves if required. + log.Info("Skipping chown: %v", err) + } + } + return nil +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-4.30.6/pkg/yqlib/chown_not_linux_os.go new/yq-4.30.8/pkg/yqlib/chown_not_linux_os.go --- old/yq-4.30.6/pkg/yqlib/chown_not_linux_os.go 1970-01-01 01:00:00.000000000 +0100 +++ new/yq-4.30.8/pkg/yqlib/chown_not_linux_os.go 2023-01-15 01:37:07.000000000 +0100 @@ -0,0 +1,12 @@ +//go:build !linux + +package yqlib + +import ( + "io/fs" + "os" +) + +func changeOwner(info fs.FileInfo, file *os.File) error { + return nil +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-4.30.6/pkg/yqlib/decoder_properties.go new/yq-4.30.8/pkg/yqlib/decoder_properties.go --- old/yq-4.30.6/pkg/yqlib/decoder_properties.go 2022-12-17 01:16:38.000000000 +0100 +++ new/yq-4.30.8/pkg/yqlib/decoder_properties.go 2023-01-15 01:37:07.000000000 +0100 @@ -63,7 +63,7 @@ rhsCandidateNode.Node.Tag = guessTagFromCustomType(rhsCandidateNode.Node) - rhsOp := &Operation{OperationType: valueOpType, CandidateNode: rhsCandidateNode} + rhsOp := &Operation{OperationType: referenceOpType, CandidateNode: rhsCandidateNode} assignmentOpNode := &ExpressionNode{ Operation: assignmentOp, @@ -102,7 +102,7 @@ assignmentOp := &Operation{OperationType: assignOpType, Preferences: assignPreferences{}} - rhsOp := &Operation{OperationType: valueOpType, CandidateNode: rhsCandidateNode} + rhsOp := &Operation{OperationType: referenceOpType, CandidateNode: rhsCandidateNode} assignmentOpNode := &ExpressionNode{ Operation: assignmentOp, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-4.30.6/pkg/yqlib/doc/operators/add.md new/yq-4.30.8/pkg/yqlib/doc/operators/add.md --- old/yq-4.30.6/pkg/yqlib/doc/operators/add.md 2022-12-17 01:16:38.000000000 +0100 +++ new/yq-4.30.8/pkg/yqlib/doc/operators/add.md 2023-01-15 01:37:07.000000000 +0100 @@ -86,6 +86,23 @@ a: ['dog', 'cat'] ``` +## Prepend to existing array +Given a sample.yml file of: +```yaml +a: + - dog +``` +then +```bash +yq '.a = ["cat"] + .a' sample.yml +``` +will output +```yaml +a: + - cat + - dog +``` + ## Add new object to array Given a sample.yml file of: ```yaml diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-4.30.6/pkg/yqlib/doc/operators/multiply-merge.md new/yq-4.30.8/pkg/yqlib/doc/operators/multiply-merge.md --- old/yq-4.30.6/pkg/yqlib/doc/operators/multiply-merge.md 2022-12-17 01:16:38.000000000 +0100 +++ new/yq-4.30.8/pkg/yqlib/doc/operators/multiply-merge.md 2023-01-15 01:37:07.000000000 +0100 @@ -499,3 +499,43 @@ dog: woof ``` +## Merging a null with a map +Running +```bash +yq --null-input 'null * {"some": "thing"}' +``` +will output +```yaml +some: thing +``` + +## Merging a map with null +Running +```bash +yq --null-input '{"some": "thing"} * null' +``` +will output +```yaml +some: thing +``` + +## Merging an null with an array +Running +```bash +yq --null-input 'null * ["some"]' +``` +will output +```yaml +- some +``` + +## Merging an array with null +Running +```bash +yq --null-input '["some"] * null' +``` +will output +```yaml +- some +``` + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-4.30.6/pkg/yqlib/lexer_participle_test.go new/yq-4.30.8/pkg/yqlib/lexer_participle_test.go --- old/yq-4.30.6/pkg/yqlib/lexer_participle_test.go 2022-12-17 01:16:38.000000000 +0100 +++ new/yq-4.30.8/pkg/yqlib/lexer_participle_test.go 2023-01-15 01:37:07.000000000 +0100 @@ -61,7 +61,7 @@ TokenType: operationToken, Operation: &Operation{ OperationType: valueOpType, - Value: 3, + Value: int64(3), StringValue: "3", CandidateNode: &CandidateNode{ Node: &yaml.Node{ @@ -103,7 +103,7 @@ TokenType: operationToken, Operation: &Operation{ OperationType: valueOpType, - Value: -2, + Value: int64(-2), StringValue: "-2", CandidateNode: &CandidateNode{ Node: &yaml.Node{ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-4.30.6/pkg/yqlib/lib.go new/yq-4.30.8/pkg/yqlib/lib.go --- old/yq-4.30.6/pkg/yqlib/lib.go 2022-12-17 01:16:38.000000000 +0100 +++ new/yq-4.30.8/pkg/yqlib/lib.go 2023-01-15 01:37:07.000000000 +0100 @@ -155,6 +155,7 @@ var selfReferenceOpType = &operationType{Type: "SELF", NumArgs: 0, Precedence: 55, Handler: selfOperator} var valueOpType = &operationType{Type: "VALUE", NumArgs: 0, Precedence: 50, Handler: valueOperator} +var referenceOpType = &operationType{Type: "REF", NumArgs: 0, Precedence: 50, Handler: referenceOperator} var envOpType = &operationType{Type: "ENV", NumArgs: 0, Precedence: 50, Handler: envOperator} var notOpType = &operationType{Type: "NOT", NumArgs: 0, Precedence: 50, Handler: notOperator} var emptyOpType = &operationType{Type: "EMPTY", Precedence: 50, Handler: emptyOperator} @@ -416,6 +417,7 @@ } func createValueOperation(value interface{}, stringValue string) *Operation { + log.Debug("creating value op for string %v", stringValue) var node = createScalarNode(value, stringValue) return &Operation{ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-4.30.6/pkg/yqlib/operator_add_test.go new/yq-4.30.8/pkg/yqlib/operator_add_test.go --- old/yq-4.30.6/pkg/yqlib/operator_add_test.go 2022-12-17 01:16:38.000000000 +0100 +++ new/yq-4.30.8/pkg/yqlib/operator_add_test.go 2023-01-15 01:37:07.000000000 +0100 @@ -102,6 +102,14 @@ }, }, { + description: "Prepend to existing array", + document: `a: [dog]`, + expression: `.a = ["cat"] + .a`, + expected: []string{ + "D0, P[], (doc)::a: [cat, dog]\n", + }, + }, + { skipDoc: true, description: "Concatenate to existing array", subdescription: "does not modify original", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-4.30.6/pkg/yqlib/operator_multiply.go new/yq-4.30.8/pkg/yqlib/operator_multiply.go --- old/yq-4.30.6/pkg/yqlib/operator_multiply.go 2022-12-17 01:16:38.000000000 +0100 +++ new/yq-4.30.8/pkg/yqlib/operator_multiply.go 2023-01-15 01:37:07.000000000 +0100 @@ -60,8 +60,14 @@ log.Debugf("Multiplying LHS: %v", lhs.Node.Tag) log.Debugf("- RHS: %v", rhs.Node.Tag) - if lhs.Node.Kind == yaml.MappingNode && rhs.Node.Kind == yaml.MappingNode || - (lhs.Node.Kind == yaml.SequenceNode && rhs.Node.Kind == yaml.SequenceNode) { + if rhs.Node.Tag == "!!null" { + return lhs.Copy() + } + + if (lhs.Node.Kind == yaml.MappingNode && rhs.Node.Kind == yaml.MappingNode) || + (lhs.Node.Tag == "!!null" && rhs.Node.Kind == yaml.MappingNode) || + (lhs.Node.Kind == yaml.SequenceNode && rhs.Node.Kind == yaml.SequenceNode) || + (lhs.Node.Tag == "!!null" && rhs.Node.Kind == yaml.SequenceNode) { var newBlank = CandidateNode{} err := copier.CopyWithOption(&newBlank, lhs, copier.Option{IgnoreEmpty: true, DeepCopy: true}) if err != nil { @@ -189,7 +195,7 @@ } else { log.Debugf("merge - assignmentOp := &Operation{OperationType: assignAttributesOpType}") } - rhsOp := &Operation{OperationType: valueOpType, CandidateNode: rhs} + rhsOp := &Operation{OperationType: referenceOpType, CandidateNode: rhs} assignmentOpNode := &ExpressionNode{ Operation: assignmentOp, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-4.30.6/pkg/yqlib/operator_multiply_test.go new/yq-4.30.8/pkg/yqlib/operator_multiply_test.go --- old/yq-4.30.6/pkg/yqlib/operator_multiply_test.go 2022-12-17 01:16:38.000000000 +0100 +++ new/yq-4.30.8/pkg/yqlib/operator_multiply_test.go 2023-01-15 01:37:07.000000000 +0100 @@ -579,6 +579,41 @@ "D0, P[], (doc)::a: {a: apple is included, b: cool.}\n", }, }, + { + description: "Merging a null with a map", + expression: `null * {"some": "thing"}`, + expected: []string{ + "D0, P[], (!!map)::some: thing\n", + }, + }, + { + description: "Merging a map with null", + expression: `{"some": "thing"} * null`, + expected: []string{ + "D0, P[], (!!map)::some: thing\n", + }, + }, + { + description: "Merging an null with an array", + expression: `null * ["some"]`, + expected: []string{ + "D0, P[], (!!seq)::- some\n", + }, + }, + { + description: "Merging an array with null", + expression: `["some"] * null`, + expected: []string{ + "D0, P[], (!!seq)::- some\n", + }, + }, + { + skipDoc: true, + expression: `null * null`, + expected: []string{ + "D0, P[], (!!null)::null\n", + }, + }, } func TestMultiplyOperatorScenarios(t *testing.T) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-4.30.6/pkg/yqlib/operator_path.go new/yq-4.30.8/pkg/yqlib/operator_path.go --- old/yq-4.30.6/pkg/yqlib/operator_path.go 2022-12-17 01:16:38.000000000 +0100 +++ new/yq-4.30.8/pkg/yqlib/operator_path.go 2023-01-15 01:37:07.000000000 +0100 @@ -81,7 +81,7 @@ return Context{}, fmt.Errorf("SETPATH: expected single value on RHS but found %v", targetContextValue.MatchingNodes.Len()) } - rhsOp := &Operation{OperationType: valueOpType, CandidateNode: targetContextValue.MatchingNodes.Front().Value.(*CandidateNode)} + rhsOp := &Operation{OperationType: referenceOpType, CandidateNode: targetContextValue.MatchingNodes.Front().Value.(*CandidateNode)} assignmentOpNode := &ExpressionNode{ Operation: assignmentOp, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-4.30.6/pkg/yqlib/operator_slice.go new/yq-4.30.8/pkg/yqlib/operator_slice.go --- old/yq-4.30.6/pkg/yqlib/operator_slice.go 2022-12-17 01:16:38.000000000 +0100 +++ new/yq-4.30.8/pkg/yqlib/operator_slice.go 2023-01-15 01:37:07.000000000 +0100 @@ -48,6 +48,8 @@ relativeSecondNumber := secondNumber if relativeSecondNumber < 0 { relativeSecondNumber = len(original.Content) + secondNumber + } else if relativeSecondNumber > len(original.Content) { + relativeSecondNumber = len(original.Content) } log.Debug("calculateIndicesToTraverse: slice from %v to %v", relativeFirstNumber, relativeSecondNumber) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-4.30.6/pkg/yqlib/operator_slice_test.go new/yq-4.30.8/pkg/yqlib/operator_slice_test.go --- old/yq-4.30.6/pkg/yqlib/operator_slice_test.go 2022-12-17 01:16:38.000000000 +0100 +++ new/yq-4.30.8/pkg/yqlib/operator_slice_test.go 2023-01-15 01:37:07.000000000 +0100 @@ -56,6 +56,24 @@ }, }, { + skipDoc: true, + description: "second index beyond array clamps", + document: `[cat]`, + expression: `.[:3]`, + expected: []string{ + "D0, P[], (!!seq)::- cat\n", + }, + }, + { + skipDoc: true, + description: "first index beyond array returns nothing", + document: `[cat]`, + expression: `.[3:]`, + expected: []string{ + "D0, P[], (!!seq)::[]\n", + }, + }, + { skipDoc: true, document: `[[cat, dog, frog, cow], [apple, banana, grape, mango]]`, expression: `.[] | .[-2:-1]`, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-4.30.6/pkg/yqlib/operator_value.go new/yq-4.30.8/pkg/yqlib/operator_value.go --- old/yq-4.30.6/pkg/yqlib/operator_value.go 2022-12-17 01:16:38.000000000 +0100 +++ new/yq-4.30.8/pkg/yqlib/operator_value.go 2023-01-15 01:37:07.000000000 +0100 @@ -1,6 +1,30 @@ package yqlib +import "container/list" + +func referenceOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) { + return context.SingleChildContext(expressionNode.Operation.CandidateNode), nil +} + func valueOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) { log.Debug("value = %v", expressionNode.Operation.CandidateNode.Node.Value) - return context.SingleChildContext(expressionNode.Operation.CandidateNode), nil + if context.MatchingNodes.Len() == 0 { + clone, err := expressionNode.Operation.CandidateNode.Copy() + if err != nil { + return Context{}, err + } + return context.SingleChildContext(clone), nil + } + + var results = list.New() + + for el := context.MatchingNodes.Front(); el != nil; el = el.Next() { + clone, err := expressionNode.Operation.CandidateNode.Copy() + if err != nil { + return Context{}, err + } + results.PushBack(clone) + } + + return context.ChildContext(results), nil } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-4.30.6/pkg/yqlib/operator_value_test.go new/yq-4.30.8/pkg/yqlib/operator_value_test.go --- old/yq-4.30.6/pkg/yqlib/operator_value_test.go 2022-12-17 01:16:38.000000000 +0100 +++ new/yq-4.30.8/pkg/yqlib/operator_value_test.go 2023-01-15 01:37:07.000000000 +0100 @@ -13,6 +13,28 @@ }, }, { + document: `[1,2,3]`, + expression: `.[] | "foo"`, + expected: []string{ + "D0, P[], (!!str)::foo\n", + "D0, P[], (!!str)::foo\n", + "D0, P[], (!!str)::foo\n", + }, + }, + { + document: `[1,2,3]`, + expression: `[.[] | "foo"] | .[0] = "cat"`, + expected: []string{ + "D0, P[], (!!seq)::- cat\n- foo\n- foo\n", + }, + }, + { + expression: `"foo"`, + expected: []string{ + "D0, P[], (!!str)::foo\n", + }, + }, + { document: ``, expression: `0x9f`, expected: []string{ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-4.30.6/pkg/yqlib/operators.go new/yq-4.30.8/pkg/yqlib/operators.go --- old/yq-4.30.6/pkg/yqlib/operators.go 2022-12-17 01:16:38.000000000 +0100 +++ new/yq-4.30.8/pkg/yqlib/operators.go 2023-01-15 01:37:07.000000000 +0100 @@ -41,9 +41,9 @@ if err != nil { return Context{}, err } - valueCopyExp := &ExpressionNode{Operation: &Operation{OperationType: valueOpType, CandidateNode: clone}} + valueCopyExp := &ExpressionNode{Operation: &Operation{OperationType: referenceOpType, CandidateNode: clone}} - valueExpression := &ExpressionNode{Operation: &Operation{OperationType: valueOpType, CandidateNode: candidate}} + valueExpression := &ExpressionNode{Operation: &Operation{OperationType: referenceOpType, CandidateNode: candidate}} assignmentOpNode := &ExpressionNode{Operation: assignmentOp, LHS: valueExpression, RHS: calculation(valueCopyExp, expressionNode.RHS)} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-4.30.6/pkg/yqlib/write_in_place_handler.go new/yq-4.30.8/pkg/yqlib/write_in_place_handler.go --- old/yq-4.30.6/pkg/yqlib/write_in_place_handler.go 2022-12-17 01:16:38.000000000 +0100 +++ new/yq-4.30.8/pkg/yqlib/write_in_place_handler.go 2023-01-15 01:37:07.000000000 +0100 @@ -34,6 +34,10 @@ if err != nil { return nil, err } + + if err = changeOwner(info, file); err != nil { + return nil, err + } log.Debug("WriteInPlaceHandler: writing to tempfile: %v", file.Name()) w.tempFile = file return file, err diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-4.30.6/release_notes.txt new/yq-4.30.8/release_notes.txt --- old/yq-4.30.6/release_notes.txt 2022-12-17 01:16:38.000000000 +0100 +++ new/yq-4.30.8/release_notes.txt 2023-01-15 01:37:07.000000000 +0100 @@ -1,3 +1,14 @@ +4.30.8: + - Log info message when unable to chown file in linux (e.g. snap confinement) #1521 + + +4.30.7: + - Fixed bug in splice operator #1511 + - Fixed value operator bug #1515 + - Fixed handling of merging null #1501 + - Ownership of file now maintained in linux (thanks @vaguecoder) #1473 + - Bumped dependency versions + 4.30.6: - Fixed xml comment in array of scalars #1465 - Include blank new lines in leading header preprocessing #1462 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yq-4.30.6/snap/snapcraft.yaml new/yq-4.30.8/snap/snapcraft.yaml --- old/yq-4.30.6/snap/snapcraft.yaml 2022-12-17 01:16:38.000000000 +0100 +++ new/yq-4.30.8/snap/snapcraft.yaml 2023-01-15 01:37:07.000000000 +0100 @@ -1,5 +1,5 @@ name: yq -version: 'v4.30.6' +version: 'v4.30.8' summary: A lightweight and portable command-line YAML processor description: | The aim of the project is to be the jq or sed of yaml files.