From 58c95148e20218f4607e9a2a12f18e15e7185e11 Mon Sep 17 00:00:00 2001 From: kt Date: Wed, 10 Aug 2022 12:38:14 -0700 Subject: [PATCH 1/2] fix vendor deps --- cli/cmds.go | 6 +++--- go.mod | 4 ++-- go.sum | 8 +++++--- .../diff => katbyte/andreyvit-diff}/.gitignore | 0 .../diff => katbyte/andreyvit-diff}/LICENSE | 0 .../diff => katbyte/andreyvit-diff}/README.md | 0 .../diff => katbyte/andreyvit-diff}/diff.go | 2 +- .../diff => katbyte/andreyvit-diff}/doc.go | 0 .../diff => katbyte/andreyvit-diff}/trim.go | 0 .../{sergi/go-diff => katbyte/sergi-go-diff}/AUTHORS | 0 .../go-diff => katbyte/sergi-go-diff}/CONTRIBUTORS | 0 .../{sergi/go-diff => katbyte/sergi-go-diff}/LICENSE | 0 .../sergi-go-diff}/diffmatchpatch/diff.go | 0 .../sergi-go-diff}/diffmatchpatch/diffmatchpatch.go | 0 .../sergi-go-diff}/diffmatchpatch/match.go | 0 .../sergi-go-diff}/diffmatchpatch/mathutil.go | 0 .../diffmatchpatch/operation_string.go | 0 .../sergi-go-diff}/diffmatchpatch/patch.go | 0 .../sergi-go-diff}/diffmatchpatch/stringutil.go | 0 vendor/modules.txt | 12 ++++++------ 20 files changed, 17 insertions(+), 15 deletions(-) rename vendor/github.com/{andreyvit/diff => katbyte/andreyvit-diff}/.gitignore (100%) rename vendor/github.com/{andreyvit/diff => katbyte/andreyvit-diff}/LICENSE (100%) rename vendor/github.com/{andreyvit/diff => katbyte/andreyvit-diff}/README.md (100%) rename vendor/github.com/{andreyvit/diff => katbyte/andreyvit-diff}/diff.go (98%) rename vendor/github.com/{andreyvit/diff => katbyte/andreyvit-diff}/doc.go (100%) rename vendor/github.com/{andreyvit/diff => katbyte/andreyvit-diff}/trim.go (100%) rename vendor/github.com/{sergi/go-diff => katbyte/sergi-go-diff}/AUTHORS (100%) rename vendor/github.com/{sergi/go-diff => katbyte/sergi-go-diff}/CONTRIBUTORS (100%) rename vendor/github.com/{sergi/go-diff => katbyte/sergi-go-diff}/LICENSE (100%) rename vendor/github.com/{sergi/go-diff => katbyte/sergi-go-diff}/diffmatchpatch/diff.go (100%) rename vendor/github.com/{sergi/go-diff => katbyte/sergi-go-diff}/diffmatchpatch/diffmatchpatch.go (100%) rename vendor/github.com/{sergi/go-diff => katbyte/sergi-go-diff}/diffmatchpatch/match.go (100%) rename vendor/github.com/{sergi/go-diff => katbyte/sergi-go-diff}/diffmatchpatch/mathutil.go (100%) rename vendor/github.com/{sergi/go-diff => katbyte/sergi-go-diff}/diffmatchpatch/operation_string.go (100%) rename vendor/github.com/{sergi/go-diff => katbyte/sergi-go-diff}/diffmatchpatch/patch.go (100%) rename vendor/github.com/{sergi/go-diff => katbyte/sergi-go-diff}/diffmatchpatch/stringutil.go (100%) diff --git a/cli/cmds.go b/cli/cmds.go index 8a2244bc..dcaf7054 100644 --- a/cli/cmds.go +++ b/cli/cmds.go @@ -12,9 +12,9 @@ import ( "path/filepath" "strings" - "github.com/andreyvit/diff" c "github.com/gookit/color" "github.com/hashicorp/go-multierror" + diff "github.com/katbyte/andreyvit-diff" "github.com/katbyte/terrafmt/lib/blocks" "github.com/katbyte/terrafmt/lib/common" verbs "github.com/katbyte/terrafmt/lib/fmtverbs" @@ -380,7 +380,7 @@ func (w jsonBlockWriter) Close() error { func findBlocksInFile(fs afero.Fs, log *logrus.Logger, filename string, verbose, zeroTerminated, jsonOutput, fmtverbs bool, stdin io.Reader, stdout, stderr io.Writer) error { var blockWriter blocks.BlockWriter - //nolint: gocritic + // nolint: gocritic if zeroTerminated { blockWriter = zeroTerminatedBlockWriter{ writer: stdout, @@ -464,7 +464,7 @@ func diffFile(fs afero.Fs, log *logrus.Logger, filename string, fmtverbs, verbos for scanner.Scan() { l := scanner.Text() - //nolint: gocritic + // nolint: gocritic if strings.HasPrefix(l, "+") { fmt.Fprint(outW, c.Sprintf("%s\n", l)) } else if strings.HasPrefix(l, "-") { diff --git a/go.mod b/go.mod index 56f14cd1..90655f71 100644 --- a/go.mod +++ b/go.mod @@ -3,13 +3,13 @@ module github.com/katbyte/terrafmt go 1.18 require ( - github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 github.com/gookit/color v1.5.1 github.com/hashicorp/go-multierror v1.1.1 github.com/hashicorp/go-version v1.6.0 github.com/hashicorp/hc-install v0.4.0 github.com/hashicorp/hcl/v2 v2.13.0 github.com/hashicorp/terraform-exec v0.17.2 + github.com/katbyte/andreyvit-diff v0.0.1 github.com/kylelemons/godebug v1.1.0 github.com/sirupsen/logrus v1.9.0 github.com/spf13/afero v1.9.2 @@ -29,12 +29,12 @@ require ( github.com/hashicorp/hcl v1.0.0 // indirect github.com/hashicorp/terraform-json v0.14.0 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect + github.com/katbyte/sergi-go-diff v1.1.1 // indirect github.com/magiconair/properties v1.8.6 // indirect github.com/mitchellh/go-wordwrap v1.0.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml/v2 v2.0.1 // indirect - github.com/sergi/go-diff v1.1.0 // indirect github.com/spf13/cast v1.5.0 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect diff --git a/go.sum b/go.sum index 4708123c..7d6ef8ed 100644 --- a/go.sum +++ b/go.sum @@ -47,8 +47,6 @@ github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= -github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= -github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= @@ -186,6 +184,10 @@ github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= +github.com/katbyte/andreyvit-diff v0.0.1 h1:2u6ofZeHrVgJjUzJ6JFlcfb3LeDq0rHxUH+WMHerELo= +github.com/katbyte/andreyvit-diff v0.0.1/go.mod h1:F6SME78YVaEk4agzLHhmsVwdVU+o/CtRnR0Bl9qBfrI= +github.com/katbyte/sergi-go-diff v1.1.1 h1:HelbPXYFHziR633zFq8QzwDY44jQ0Xy7COcLxNEWJtY= +github.com/katbyte/sergi-go-diff v1.1.1/go.mod h1:BxkLLDDB1iVQsnURErqoQMjkyXIlR0DefDKzZCUHNEw= github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 h1:DowS9hvgyYSX4TO5NpyC606/Z4SxnNYbT+WX27or6Ck= github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= @@ -227,8 +229,8 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4= -github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= +github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= diff --git a/vendor/github.com/andreyvit/diff/.gitignore b/vendor/github.com/katbyte/andreyvit-diff/.gitignore similarity index 100% rename from vendor/github.com/andreyvit/diff/.gitignore rename to vendor/github.com/katbyte/andreyvit-diff/.gitignore diff --git a/vendor/github.com/andreyvit/diff/LICENSE b/vendor/github.com/katbyte/andreyvit-diff/LICENSE similarity index 100% rename from vendor/github.com/andreyvit/diff/LICENSE rename to vendor/github.com/katbyte/andreyvit-diff/LICENSE diff --git a/vendor/github.com/andreyvit/diff/README.md b/vendor/github.com/katbyte/andreyvit-diff/README.md similarity index 100% rename from vendor/github.com/andreyvit/diff/README.md rename to vendor/github.com/katbyte/andreyvit-diff/README.md diff --git a/vendor/github.com/andreyvit/diff/diff.go b/vendor/github.com/katbyte/andreyvit-diff/diff.go similarity index 98% rename from vendor/github.com/andreyvit/diff/diff.go rename to vendor/github.com/katbyte/andreyvit-diff/diff.go index 12953c83..47837203 100644 --- a/vendor/github.com/andreyvit/diff/diff.go +++ b/vendor/github.com/katbyte/andreyvit-diff/diff.go @@ -4,7 +4,7 @@ import ( "bytes" "strings" - "github.com/sergi/go-diff/diffmatchpatch" + "github.com/katbyte/sergi-go-diff/diffmatchpatch" ) func diff(a, b string) []diffmatchpatch.Diff { diff --git a/vendor/github.com/andreyvit/diff/doc.go b/vendor/github.com/katbyte/andreyvit-diff/doc.go similarity index 100% rename from vendor/github.com/andreyvit/diff/doc.go rename to vendor/github.com/katbyte/andreyvit-diff/doc.go diff --git a/vendor/github.com/andreyvit/diff/trim.go b/vendor/github.com/katbyte/andreyvit-diff/trim.go similarity index 100% rename from vendor/github.com/andreyvit/diff/trim.go rename to vendor/github.com/katbyte/andreyvit-diff/trim.go diff --git a/vendor/github.com/sergi/go-diff/AUTHORS b/vendor/github.com/katbyte/sergi-go-diff/AUTHORS similarity index 100% rename from vendor/github.com/sergi/go-diff/AUTHORS rename to vendor/github.com/katbyte/sergi-go-diff/AUTHORS diff --git a/vendor/github.com/sergi/go-diff/CONTRIBUTORS b/vendor/github.com/katbyte/sergi-go-diff/CONTRIBUTORS similarity index 100% rename from vendor/github.com/sergi/go-diff/CONTRIBUTORS rename to vendor/github.com/katbyte/sergi-go-diff/CONTRIBUTORS diff --git a/vendor/github.com/sergi/go-diff/LICENSE b/vendor/github.com/katbyte/sergi-go-diff/LICENSE similarity index 100% rename from vendor/github.com/sergi/go-diff/LICENSE rename to vendor/github.com/katbyte/sergi-go-diff/LICENSE diff --git a/vendor/github.com/sergi/go-diff/diffmatchpatch/diff.go b/vendor/github.com/katbyte/sergi-go-diff/diffmatchpatch/diff.go similarity index 100% rename from vendor/github.com/sergi/go-diff/diffmatchpatch/diff.go rename to vendor/github.com/katbyte/sergi-go-diff/diffmatchpatch/diff.go diff --git a/vendor/github.com/sergi/go-diff/diffmatchpatch/diffmatchpatch.go b/vendor/github.com/katbyte/sergi-go-diff/diffmatchpatch/diffmatchpatch.go similarity index 100% rename from vendor/github.com/sergi/go-diff/diffmatchpatch/diffmatchpatch.go rename to vendor/github.com/katbyte/sergi-go-diff/diffmatchpatch/diffmatchpatch.go diff --git a/vendor/github.com/sergi/go-diff/diffmatchpatch/match.go b/vendor/github.com/katbyte/sergi-go-diff/diffmatchpatch/match.go similarity index 100% rename from vendor/github.com/sergi/go-diff/diffmatchpatch/match.go rename to vendor/github.com/katbyte/sergi-go-diff/diffmatchpatch/match.go diff --git a/vendor/github.com/sergi/go-diff/diffmatchpatch/mathutil.go b/vendor/github.com/katbyte/sergi-go-diff/diffmatchpatch/mathutil.go similarity index 100% rename from vendor/github.com/sergi/go-diff/diffmatchpatch/mathutil.go rename to vendor/github.com/katbyte/sergi-go-diff/diffmatchpatch/mathutil.go diff --git a/vendor/github.com/sergi/go-diff/diffmatchpatch/operation_string.go b/vendor/github.com/katbyte/sergi-go-diff/diffmatchpatch/operation_string.go similarity index 100% rename from vendor/github.com/sergi/go-diff/diffmatchpatch/operation_string.go rename to vendor/github.com/katbyte/sergi-go-diff/diffmatchpatch/operation_string.go diff --git a/vendor/github.com/sergi/go-diff/diffmatchpatch/patch.go b/vendor/github.com/katbyte/sergi-go-diff/diffmatchpatch/patch.go similarity index 100% rename from vendor/github.com/sergi/go-diff/diffmatchpatch/patch.go rename to vendor/github.com/katbyte/sergi-go-diff/diffmatchpatch/patch.go diff --git a/vendor/github.com/sergi/go-diff/diffmatchpatch/stringutil.go b/vendor/github.com/katbyte/sergi-go-diff/diffmatchpatch/stringutil.go similarity index 100% rename from vendor/github.com/sergi/go-diff/diffmatchpatch/stringutil.go rename to vendor/github.com/katbyte/sergi-go-diff/diffmatchpatch/stringutil.go diff --git a/vendor/modules.txt b/vendor/modules.txt index 7193999d..d616f794 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,9 +1,6 @@ # github.com/agext/levenshtein v1.2.3 ## explicit github.com/agext/levenshtein -# github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 -## explicit -github.com/andreyvit/diff # github.com/apparentlymart/go-textseg/v13 v13.0.0 ## explicit; go 1.16 github.com/apparentlymart/go-textseg/v13/textseg @@ -74,6 +71,12 @@ github.com/hashicorp/terraform-json # github.com/inconshreveable/mousetrap v1.0.0 ## explicit github.com/inconshreveable/mousetrap +# github.com/katbyte/andreyvit-diff v0.0.1 +## explicit; go 1.19 +github.com/katbyte/andreyvit-diff +# github.com/katbyte/sergi-go-diff v1.1.1 +## explicit; go 1.18 +github.com/katbyte/sergi-go-diff/diffmatchpatch # github.com/kylelemons/godebug v1.1.0 ## explicit; go 1.11 github.com/kylelemons/godebug/diff @@ -95,9 +98,6 @@ github.com/pelletier/go-toml/v2 github.com/pelletier/go-toml/v2/internal/ast github.com/pelletier/go-toml/v2/internal/danger github.com/pelletier/go-toml/v2/internal/tracker -# github.com/sergi/go-diff v1.1.0 -## explicit; go 1.12 -github.com/sergi/go-diff/diffmatchpatch # github.com/sirupsen/logrus v1.9.0 ## explicit; go 1.13 github.com/sirupsen/logrus From 2c09c7c7b1a8fd3b5a4aa2c48b7c27c06e6ab5c8 Mon Sep 17 00:00:00 2001 From: kt Date: Wed, 10 Aug 2022 12:53:31 -0700 Subject: [PATCH 2/2] try 1.2.1 --- go.mod | 4 +- go.sum | 8 +- .../katbyte/andreyvit-diff/.gitignore | 30 ++-- .../sergi-go-diff/diffmatchpatch/diff.go | 138 +++++++++--------- .../sergi-go-diff/diffmatchpatch/patch.go | 2 +- .../diffmatchpatch/stringutil.go | 18 +++ vendor/modules.txt | 4 +- 7 files changed, 110 insertions(+), 94 deletions(-) diff --git a/go.mod b/go.mod index 90655f71..af46c53e 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/hashicorp/hc-install v0.4.0 github.com/hashicorp/hcl/v2 v2.13.0 github.com/hashicorp/terraform-exec v0.17.2 - github.com/katbyte/andreyvit-diff v0.0.1 + github.com/katbyte/andreyvit-diff v0.0.2 github.com/kylelemons/godebug v1.1.0 github.com/sirupsen/logrus v1.9.0 github.com/spf13/afero v1.9.2 @@ -29,7 +29,7 @@ require ( github.com/hashicorp/hcl v1.0.0 // indirect github.com/hashicorp/terraform-json v0.14.0 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect - github.com/katbyte/sergi-go-diff v1.1.1 // indirect + github.com/katbyte/sergi-go-diff v1.2.1 // indirect github.com/magiconair/properties v1.8.6 // indirect github.com/mitchellh/go-wordwrap v1.0.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect diff --git a/go.sum b/go.sum index 7d6ef8ed..2adab693 100644 --- a/go.sum +++ b/go.sum @@ -184,10 +184,10 @@ github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/katbyte/andreyvit-diff v0.0.1 h1:2u6ofZeHrVgJjUzJ6JFlcfb3LeDq0rHxUH+WMHerELo= -github.com/katbyte/andreyvit-diff v0.0.1/go.mod h1:F6SME78YVaEk4agzLHhmsVwdVU+o/CtRnR0Bl9qBfrI= -github.com/katbyte/sergi-go-diff v1.1.1 h1:HelbPXYFHziR633zFq8QzwDY44jQ0Xy7COcLxNEWJtY= -github.com/katbyte/sergi-go-diff v1.1.1/go.mod h1:BxkLLDDB1iVQsnURErqoQMjkyXIlR0DefDKzZCUHNEw= +github.com/katbyte/andreyvit-diff v0.0.2 h1:uQGxP2z57bTUGn3SCFzYKgtIKLeuYE+k9dxq1u9Js7U= +github.com/katbyte/andreyvit-diff v0.0.2/go.mod h1:TdKKfasbASLXZHMVyCoXJw999kjRmOIeHSdG1Pm/x1Y= +github.com/katbyte/sergi-go-diff v1.2.1 h1:etD07v2OL+HOzN32zF202yZbpzoUkizbfvbggpBSn/s= +github.com/katbyte/sergi-go-diff v1.2.1/go.mod h1:BxkLLDDB1iVQsnURErqoQMjkyXIlR0DefDKzZCUHNEw= github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 h1:DowS9hvgyYSX4TO5NpyC606/Z4SxnNYbT+WX27or6Ck= github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= diff --git a/vendor/github.com/katbyte/andreyvit-diff/.gitignore b/vendor/github.com/katbyte/andreyvit-diff/.gitignore index daf913b1..f96564a0 100644 --- a/vendor/github.com/katbyte/andreyvit-diff/.gitignore +++ b/vendor/github.com/katbyte/andreyvit-diff/.gitignore @@ -1,24 +1,14 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so +## rubymine project files +.idea -# Folders -_obj -_test +# Binaries for programs and plugins +/terrafmt -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* +# Test binary, built with `go test -c` +*.test -_testmain.go +# Output of the go coverage tool, specifically when used with LiteIDE +*.out -*.exe -*.test -*.prof +# macOS Finder.app +.DS_STORE diff --git a/vendor/github.com/katbyte/sergi-go-diff/diffmatchpatch/diff.go b/vendor/github.com/katbyte/sergi-go-diff/diffmatchpatch/diff.go index cb25b437..a6f6d1fe 100644 --- a/vendor/github.com/katbyte/sergi-go-diff/diffmatchpatch/diff.go +++ b/vendor/github.com/katbyte/sergi-go-diff/diffmatchpatch/diff.go @@ -34,6 +34,8 @@ const ( DiffInsert Operation = 1 // DiffEqual item represents an equal diff. DiffEqual Operation = 0 + // IndexSeparator is used to seperate the array indexes in an index string + IndexSeparator = "," ) // Diff represents one diff operation @@ -120,7 +122,7 @@ func (dmp *DiffMatchPatch) diffMainRunes(text1, text2 []rune, checklines bool, d // Restore the prefix and suffix. if len(commonprefix) != 0 { - diffs = append([]Diff{Diff{DiffEqual, string(commonprefix)}}, diffs...) + diffs = append([]Diff{{DiffEqual, string(commonprefix)}}, diffs...) } if len(commonsuffix) != 0 { diffs = append(diffs, Diff{DiffEqual, string(commonsuffix)}) @@ -165,8 +167,8 @@ func (dmp *DiffMatchPatch) diffCompute(text1, text2 []rune, checklines bool, dea // Single character string. // After the previous speedup, the character can't be an equality. return []Diff{ - Diff{DiffDelete, string(text1)}, - Diff{DiffInsert, string(text2)}, + {DiffDelete, string(text1)}, + {DiffInsert, string(text2)}, } // Check to see if the problem can be split in two. } else if hm := dmp.diffHalfMatch(text1, text2); hm != nil { @@ -193,7 +195,7 @@ func (dmp *DiffMatchPatch) diffCompute(text1, text2 []rune, checklines bool, dea // diffLineMode does a quick line-level diff on both []runes, then rediff the parts for greater accuracy. This speedup can produce non-minimal diffs. func (dmp *DiffMatchPatch) diffLineMode(text1, text2 []rune, deadline time.Time) []Diff { // Scan the text on a line-by-line basis first. - text1, text2, linearray := dmp.diffLinesToRunes(text1, text2) + text1, text2, linearray := dmp.DiffLinesToRunes(string(text1), string(text2)) diffs := dmp.diffMainRunes(text1, text2, false, deadline) @@ -368,8 +370,8 @@ func (dmp *DiffMatchPatch) diffBisect(runes1, runes2 []rune, deadline time.Time) } // Diff took too long and hit the deadline or number of diffs equals number of characters, no commonality at all. return []Diff{ - Diff{DiffDelete, string(runes1)}, - Diff{DiffInsert, string(runes2)}, + {DiffDelete, string(runes1)}, + {DiffInsert, string(runes2)}, } } @@ -390,66 +392,28 @@ func (dmp *DiffMatchPatch) diffBisectSplit(runes1, runes2 []rune, x, y int, // DiffLinesToChars splits two texts into a list of strings, and educes the texts to a string of hashes where each Unicode character represents one line. // It's slightly faster to call DiffLinesToRunes first, followed by DiffMainRunes. func (dmp *DiffMatchPatch) DiffLinesToChars(text1, text2 string) (string, string, []string) { - chars1, chars2, lineArray := dmp.DiffLinesToRunes(text1, text2) - return string(chars1), string(chars2), lineArray -} - -// DiffLinesToRunes splits two texts into a list of runes. Each rune represents one line. -func (dmp *DiffMatchPatch) DiffLinesToRunes(text1, text2 string) ([]rune, []rune, []string) { - // '\x00' is a valid character, but various debuggers don't like it. So we'll insert a junk entry to avoid generating a null character. - lineArray := []string{""} // e.g. lineArray[4] == 'Hello\n' - lineHash := map[string]int{} // e.g. lineHash['Hello\n'] == 4 - - chars1 := dmp.diffLinesToRunesMunge(text1, &lineArray, lineHash) - chars2 := dmp.diffLinesToRunesMunge(text2, &lineArray, lineHash) - + chars1, chars2, lineArray := dmp.diffLinesToStrings(text1, text2) return chars1, chars2, lineArray } -func (dmp *DiffMatchPatch) diffLinesToRunes(text1, text2 []rune) ([]rune, []rune, []string) { - return dmp.DiffLinesToRunes(string(text1), string(text2)) -} - -// diffLinesToRunesMunge splits a text into an array of strings, and reduces the texts to a []rune where each Unicode character represents one line. -// We use strings instead of []runes as input mainly because you can't use []rune as a map key. -func (dmp *DiffMatchPatch) diffLinesToRunesMunge(text string, lineArray *[]string, lineHash map[string]int) []rune { - // Walk the text, pulling out a substring for each line. text.split('\n') would would temporarily double our memory footprint. Modifying text would create many large strings to garbage collect. - lineStart := 0 - lineEnd := -1 - runes := []rune{} - - for lineEnd < len(text)-1 { - lineEnd = indexOf(text, "\n", lineStart) - - if lineEnd == -1 { - lineEnd = len(text) - 1 - } - - line := text[lineStart : lineEnd+1] - lineStart = lineEnd + 1 - lineValue, ok := lineHash[line] - - if ok { - runes = append(runes, rune(lineValue)) - } else { - *lineArray = append(*lineArray, line) - lineHash[line] = len(*lineArray) - 1 - runes = append(runes, rune(len(*lineArray)-1)) - } - } - - return runes +// DiffLinesToRunes splits two texts into a list of runes. +func (dmp *DiffMatchPatch) DiffLinesToRunes(text1, text2 string) ([]rune, []rune, []string) { + chars1, chars2, lineArray := dmp.diffLinesToStrings(text1, text2) + return []rune(chars1), []rune(chars2), lineArray } // DiffCharsToLines rehydrates the text in a diff from a string of line hashes to real lines of text. func (dmp *DiffMatchPatch) DiffCharsToLines(diffs []Diff, lineArray []string) []Diff { hydrated := make([]Diff, 0, len(diffs)) for _, aDiff := range diffs { - chars := aDiff.Text + chars := strings.Split(aDiff.Text, IndexSeparator) text := make([]string, len(chars)) for i, r := range chars { - text[i] = lineArray[r] + i1, err := strconv.Atoi(r) + if err == nil { + text[i] = lineArray[i1] + } } aDiff.Text = strings.Join(text, "") @@ -670,16 +634,16 @@ func (dmp *DiffMatchPatch) DiffCleanupSemantic(diffs []Diff) []Diff { // An insertion or deletion. if diffs[pointer].Type == DiffInsert { - lengthInsertions2 += len(diffs[pointer].Text) + lengthInsertions2 += utf8.RuneCountInString(diffs[pointer].Text) } else { - lengthDeletions2 += len(diffs[pointer].Text) + lengthDeletions2 += utf8.RuneCountInString(diffs[pointer].Text) } // Eliminate an equality that is smaller or equal to the edits on both sides of it. difference1 := int(math.Max(float64(lengthInsertions1), float64(lengthDeletions1))) difference2 := int(math.Max(float64(lengthInsertions2), float64(lengthDeletions2))) - if len(lastequality) > 0 && - (len(lastequality) <= difference1) && - (len(lastequality) <= difference2) { + if utf8.RuneCountInString(lastequality) > 0 && + (utf8.RuneCountInString(lastequality) <= difference1) && + (utf8.RuneCountInString(lastequality) <= difference2) { // Duplicate record. insPoint := equalities[len(equalities)-1] diffs = splice(diffs, insPoint, 0, Diff{DiffDelete, lastequality}) @@ -728,8 +692,8 @@ func (dmp *DiffMatchPatch) DiffCleanupSemantic(diffs []Diff) []Diff { overlapLength1 := dmp.DiffCommonOverlap(deletion, insertion) overlapLength2 := dmp.DiffCommonOverlap(insertion, deletion) if overlapLength1 >= overlapLength2 { - if float64(overlapLength1) >= float64(len(deletion))/2 || - float64(overlapLength1) >= float64(len(insertion))/2 { + if float64(overlapLength1) >= float64(utf8.RuneCountInString(deletion))/2 || + float64(overlapLength1) >= float64(utf8.RuneCountInString(insertion))/2 { // Overlap found. Insert an equality and trim the surrounding edits. diffs = splice(diffs, pointer, 0, Diff{DiffEqual, insertion[:overlapLength1]}) @@ -739,8 +703,8 @@ func (dmp *DiffMatchPatch) DiffCleanupSemantic(diffs []Diff) []Diff { pointer++ } } else { - if float64(overlapLength2) >= float64(len(deletion))/2 || - float64(overlapLength2) >= float64(len(insertion))/2 { + if float64(overlapLength2) >= float64(utf8.RuneCountInString(deletion))/2 || + float64(overlapLength2) >= float64(utf8.RuneCountInString(insertion))/2 { // Reverse overlap found. Insert an equality and swap and trim the surrounding edits. overlap := Diff{DiffEqual, deletion[:overlapLength2]} diffs = splice(diffs, pointer, 0, overlap) @@ -1029,7 +993,7 @@ func (dmp *DiffMatchPatch) DiffCleanupMerge(diffs []Diff) []Diff { if x > 0 && diffs[x-1].Type == DiffEqual { diffs[x-1].Text += string(textInsert[:commonlength]) } else { - diffs = append([]Diff{Diff{DiffEqual, string(textInsert[:commonlength])}}, diffs...) + diffs = append([]Diff{{DiffEqual, string(textInsert[:commonlength])}}, diffs...) pointer++ } textInsert = textInsert[commonlength:] @@ -1204,7 +1168,7 @@ func (dmp *DiffMatchPatch) DiffPrettyText(diffs []Diff) string { // DiffText1 computes and returns the source text (all equalities and deletions). func (dmp *DiffMatchPatch) DiffText1(diffs []Diff) string { - //StringBuilder text = new StringBuilder() + // StringBuilder text = new StringBuilder() var text bytes.Buffer for _, aDiff := range diffs { @@ -1343,3 +1307,47 @@ func (dmp *DiffMatchPatch) DiffFromDelta(text1 string, delta string) (diffs []Di return diffs, nil } + +// diffLinesToStrings splits two texts into a list of strings. Each string represents one line. +func (dmp *DiffMatchPatch) diffLinesToStrings(text1, text2 string) (string, string, []string) { + // '\x00' is a valid character, but various debuggers don't like it. So we'll insert a junk entry to avoid generating a null character. + lineArray := []string{""} // e.g. lineArray[4] == 'Hello\n' + lineHash := make(map[string]int) + lineHash[""] = 0 + + // Each string has the index of lineArray which it points to + strIndexArray1 := dmp.diffLinesToStringsMunge(text1, &lineArray, lineHash) + strIndexArray2 := dmp.diffLinesToStringsMunge(text2, &lineArray, lineHash) + + return intArrayToString(strIndexArray1), intArrayToString(strIndexArray2), lineArray +} + +// diffLinesToStringsMunge splits a text into an array of strings, and reduces the texts to a []string. +func (dmp *DiffMatchPatch) diffLinesToStringsMunge(text string, lineArray *[]string, lineHash map[string]int) []uint32 { + // Walk the text, pulling out a substring for each line. text.split('\n') would would temporarily double our memory footprint. Modifying text would create many large strings to garbage collect. + lineStart := 0 + lineEnd := -1 + strs := []uint32{} + + for lineEnd < len(text)-1 { + lineEnd = indexOf(text, "\n", lineStart) + + if lineEnd == -1 { + lineEnd = len(text) - 1 + } + + line := text[lineStart : lineEnd+1] + lineStart = lineEnd + 1 + lineValue, ok := lineHash[line] + + if ok { + strs = append(strs, uint32(lineValue)) + } else { + *lineArray = append(*lineArray, line) + lineHash[line] = len(*lineArray) - 1 + strs = append(strs, uint32(len(*lineArray)-1)) + } + } + + return strs +} diff --git a/vendor/github.com/katbyte/sergi-go-diff/diffmatchpatch/patch.go b/vendor/github.com/katbyte/sergi-go-diff/diffmatchpatch/patch.go index 223c43c4..0dbe3bdd 100644 --- a/vendor/github.com/katbyte/sergi-go-diff/diffmatchpatch/patch.go +++ b/vendor/github.com/katbyte/sergi-go-diff/diffmatchpatch/patch.go @@ -324,7 +324,7 @@ func (dmp *DiffMatchPatch) PatchAddPadding(patches []Patch) string { paddingLength := dmp.PatchMargin nullPadding := "" for x := 1; x <= paddingLength; x++ { - nullPadding += string(x) + nullPadding += string(rune(x)) } // Bump all the patches forward. diff --git a/vendor/github.com/katbyte/sergi-go-diff/diffmatchpatch/stringutil.go b/vendor/github.com/katbyte/sergi-go-diff/diffmatchpatch/stringutil.go index 265f29cc..44c43595 100644 --- a/vendor/github.com/katbyte/sergi-go-diff/diffmatchpatch/stringutil.go +++ b/vendor/github.com/katbyte/sergi-go-diff/diffmatchpatch/stringutil.go @@ -9,6 +9,7 @@ package diffmatchpatch import ( + "strconv" "strings" "unicode/utf8" ) @@ -86,3 +87,20 @@ func runesIndex(r1, r2 []rune) int { } return -1 } + +func intArrayToString(ns []uint32) string { + if len(ns) == 0 { + return "" + } + + indexSeparator := IndexSeparator[0] + + // Appr. 3 chars per num plus the comma. + b := []byte{} + for _, n := range ns { + b = strconv.AppendInt(b, int64(n), 10) + b = append(b, indexSeparator) + } + b = b[:len(b)-1] + return string(b) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index d616f794..496e9509 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -71,10 +71,10 @@ github.com/hashicorp/terraform-json # github.com/inconshreveable/mousetrap v1.0.0 ## explicit github.com/inconshreveable/mousetrap -# github.com/katbyte/andreyvit-diff v0.0.1 +# github.com/katbyte/andreyvit-diff v0.0.2 ## explicit; go 1.19 github.com/katbyte/andreyvit-diff -# github.com/katbyte/sergi-go-diff v1.1.1 +# github.com/katbyte/sergi-go-diff v1.2.1 ## explicit; go 1.18 github.com/katbyte/sergi-go-diff/diffmatchpatch # github.com/kylelemons/godebug v1.1.0