From a1e29602599fe2a0e37f23abc5e020742f319ea2 Mon Sep 17 00:00:00 2001 From: Jeff Bowen Date: Tue, 23 Feb 2021 20:31:25 -0500 Subject: [PATCH 1/8] Update Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c48f5da..acd1972 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ all: vet fmt lint test build build: clean which gox > /dev/null || go get -u github.com/mitchellh/gox - gox -os="linux" -os="darwin" -os="windows" -arch="amd64" -arch="386" -output="${BUILDDIR}/${BINARY}_{{.OS}}_{{.Arch}}" + gox -os="linux" -os="darwin" -os="windows" -arch="amd64" -arch="386" -arch="arm64" -output="${BUILDDIR}/${BINARY}_{{.OS}}_{{.Arch}}" gzip build/* vet: From 6112528f9e2e7cb829f7a660481c43d5bb297b97 Mon Sep 17 00:00:00 2001 From: Jeff Bowen Date: Tue, 23 Feb 2021 20:33:30 -0500 Subject: [PATCH 2/8] Go v1.16 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f9eb47f..86258dd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: go go: - - 1.13.x + - 1.16.x - master install: From bb0ee2a06165d28963419bd908891c319655a852 Mon Sep 17 00:00:00 2001 From: Jeff Bowen Date: Tue, 23 Feb 2021 20:42:38 -0500 Subject: [PATCH 3/8] Split out darwin gox cmd --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index acd1972..04df9d1 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,8 @@ all: vet fmt lint test build build: clean which gox > /dev/null || go get -u github.com/mitchellh/gox - gox -os="linux" -os="darwin" -os="windows" -arch="amd64" -arch="386" -arch="arm64" -output="${BUILDDIR}/${BINARY}_{{.OS}}_{{.Arch}}" + gox -os="linux" -os="windows" -arch="amd64" -arch="386" -output="${BUILDDIR}/${BINARY}_{{.OS}}_{{.Arch}}" + gox -os="darwin" -arch="amd64" -arch="arm64" -output="${BUILDDIR}/${BINARY}_{{.OS}}_{{.Arch}}" gzip build/* vet: From a57fd8eb8dff18eb56e8e801dd906eba2cf270e2 Mon Sep 17 00:00:00 2001 From: Jeff Bowen Date: Wed, 24 Feb 2021 11:20:12 -0500 Subject: [PATCH 4/8] add a go.mod --- go.mod | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 go.mod diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..95bccff --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/automattic/go-search-replace + +go 1.16 From 82f62b1968d9864afa8c5d3bae49c499eb7900ff Mon Sep 17 00:00:00 2001 From: Jeff Bowen Date: Wed, 24 Feb 2021 11:32:29 -0500 Subject: [PATCH 5/8] Add a comment to exported Replacement struct --- search-replace.go | 1 + 1 file changed, 1 insertion(+) diff --git a/search-replace.go b/search-replace.go index 37839fe..67dab0e 100644 --- a/search-replace.go +++ b/search-replace.go @@ -32,6 +32,7 @@ var ( bad = regexp.MustCompile(badInputRe) ) +// Replacement has two fields (both byte slices): "From" & "To" type Replacement struct { From []byte To []byte From 5fe43d8813f0f485d624e1d4ff8ad450294061e4 Mon Sep 17 00:00:00 2001 From: Jeff Bowen Date: Wed, 24 Feb 2021 11:38:44 -0500 Subject: [PATCH 6/8] gofmt -s -w search-replace_test.go --- search-replace_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/search-replace_test.go b/search-replace_test.go index 029dbc5..91945dd 100644 --- a/search-replace_test.go +++ b/search-replace_test.go @@ -18,7 +18,7 @@ func BenchmarkSimpleReplace(b *testing.B) { to := []byte("https:") for i := 0; i < b.N; i++ { replaceAndFix(&line, []*Replacement{ - &Replacement{ + { From: from, To: to, }, @@ -32,7 +32,7 @@ func BenchmarkSerializedReplace(b *testing.B) { to := []byte("https://automattic.com") for i := 0; i < b.N; i++ { replaceAndFix(&line, []*Replacement{ - &Replacement{ + { From: from, To: to, }, @@ -98,7 +98,7 @@ func TestReplace(t *testing.T) { for _, test := range tests { t.Run(test.testName, func(t *testing.T) { replaced := replaceAndFix(&test.in, []*Replacement{ - &Replacement{ + { From: test.from, To: test.to, }, @@ -123,11 +123,11 @@ func TestMultiReplace(t *testing.T) { in: []byte("http://automattic.com"), out: []byte("https://automattic.org"), replacements: []*Replacement{ - &Replacement{ + { From: []byte("http:"), To: []byte("https:"), }, - &Replacement{ + { From: []byte("automattic.com"), To: []byte("automattic.org"), }, @@ -138,11 +138,11 @@ func TestMultiReplace(t *testing.T) { in: []byte("http://automattic.com"), out: []byte("https://automattic.org"), replacements: []*Replacement{ - &Replacement{ + { From: []byte("http:"), To: []byte("https:"), }, - &Replacement{ + { From: []byte("//automattic.com"), To: []byte("//automattic.org"), }, From b6b814d0691ba8ae275b840fbd218e346ea7d498 Mon Sep 17 00:00:00 2001 From: Jeff Bowen Date: Wed, 24 Feb 2021 11:51:03 -0500 Subject: [PATCH 7/8] include arm64 in linux / windows as well --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 04df9d1..090cbea 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ all: vet fmt lint test build build: clean which gox > /dev/null || go get -u github.com/mitchellh/gox - gox -os="linux" -os="windows" -arch="amd64" -arch="386" -output="${BUILDDIR}/${BINARY}_{{.OS}}_{{.Arch}}" + gox -os="linux" -os="windows" -arch="amd64" -arch="arm64" -arch="386" -output="${BUILDDIR}/${BINARY}_{{.OS}}_{{.Arch}}" gox -os="darwin" -arch="amd64" -arch="arm64" -output="${BUILDDIR}/${BINARY}_{{.OS}}_{{.Arch}}" gzip build/* From b504d8679d36ae35d5dbb29c4048847330072c07 Mon Sep 17 00:00:00 2001 From: Jeff Bowen Date: Wed, 24 Feb 2021 12:20:00 -0500 Subject: [PATCH 8/8] recombine gox cmd and explicitly add linux & windows 386 --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 090cbea..8a91f2c 100644 --- a/Makefile +++ b/Makefile @@ -5,8 +5,7 @@ all: vet fmt lint test build build: clean which gox > /dev/null || go get -u github.com/mitchellh/gox - gox -os="linux" -os="windows" -arch="amd64" -arch="arm64" -arch="386" -output="${BUILDDIR}/${BINARY}_{{.OS}}_{{.Arch}}" - gox -os="darwin" -arch="amd64" -arch="arm64" -output="${BUILDDIR}/${BINARY}_{{.OS}}_{{.Arch}}" + gox -os="darwin" -os="linux" -os="windows" -arch="amd64" -arch="arm64" -osarch="linux/386" -osarch="windows/386" -output="${BUILDDIR}/${BINARY}_{{.OS}}_{{.Arch}}" gzip build/* vet: