From 3569c44ac1a2be06f049eb71b65b1ad42e875cd1 Mon Sep 17 00:00:00 2001 From: 012xx Date: Wed, 21 Jan 2026 08:33:35 +0000 Subject: [PATCH 1/7] update: bump Go version to 1.25 and update action versions --- .github/workflows/lint_and_tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lint_and_tests.yml b/.github/workflows/lint_and_tests.yml index abd1599..4bf5516 100644 --- a/.github/workflows/lint_and_tests.yml +++ b/.github/workflows/lint_and_tests.yml @@ -5,16 +5,16 @@ on: push: env: - go-version: 1.24 + go-version: 1.25 jobs: unit-test: timeout-minutes: 20 runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - - uses: actions/setup-go@v5 + - uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0 with: go-version: ${{ env.go-version }} From e42849f2eb3e2b282f6d26f7d909b08174133c82 Mon Sep 17 00:00:00 2001 From: 012xx Date: Wed, 21 Jan 2026 08:33:42 +0000 Subject: [PATCH 2/7] update: bump Go version to 1.25 and update dependencies --- go.mod | 8 ++++---- go.sum | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index c4fa700..bc96a20 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,9 @@ module github.com/cybozu/pre-commit-jsonnet -go 1.24 +go 1.25 -require golang.org/x/exp v0.0.0-20220428152302-39d4317da171 +require golang.org/x/exp v0.0.0-20260112195511-716be5621a96 -require github.com/sergi/go-diff v1.3.1 +require github.com/sergi/go-diff v1.4.0 -require golang.org/x/sys v0.31.0 +require golang.org/x/sys v0.40.0 diff --git a/go.sum b/go.sum index 0de3ae0..3e4a855 100644 --- a/go.sum +++ b/go.sum @@ -6,15 +6,15 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= -github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= +github.com/sergi/go-diff v1.4.0 h1:n/SP9D5ad1fORl+llWyN+D6qoUETXNZARKjyY2/KVCw= +github.com/sergi/go-diff v1.4.0/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -golang.org/x/exp v0.0.0-20220428152302-39d4317da171 h1:TfdoLivD44QwvssI9Sv1xwa5DcL5XQr4au4sZ2F2NV4= -golang.org/x/exp v0.0.0-20220428152302-39d4317da171/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE= -golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= -golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/exp v0.0.0-20260112195511-716be5621a96 h1:Z/6YuSHTLOHfNFdb8zVZomZr7cqNgTJvA8+Qz75D8gU= +golang.org/x/exp v0.0.0-20260112195511-716be5621a96/go.mod h1:nzimsREAkjBCIEFtHiYkrJyT+2uy9YZJB7H1k68CXZU= +golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ= +golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From 97af5368a4932a010ff4b2158f3f9150487ef83a Mon Sep 17 00:00:00 2001 From: 012xx Date: Wed, 21 Jan 2026 09:32:36 +0000 Subject: [PATCH 3/7] update: bump JSONNET and golangci-lint versions in Makefile --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 7a9d87d..e63a2d2 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ GIT := git PRE_COMMIT := pre-commit -JSONNET_VERSION := v0.20.0 -GOLANGCI_VERSION := v1.64.6 +JSONNET_VERSION := v0.21.0 +GOLANGCI_VERSION := v2.8.0 VERSION := v0.3.1 @@ -34,4 +34,4 @@ setup: @go install github.com/google/go-jsonnet/cmd/jsonnet-lint@$(JSONNET_VERSION) @go install github.com/google/go-jsonnet/cmd/jsonnetfmt@$(JSONNET_VERSION) - @curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin $(GOLANGCI_VERSION) + @go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_VERSION) From fc63228e178ac4abc5073afda3a134b8f39f042a Mon Sep 17 00:00:00 2001 From: 012xx Date: Wed, 21 Jan 2026 09:43:11 +0000 Subject: [PATCH 4/7] run `golangci-lint migrate` --- .golangci.bck.yaml | 6 ++++++ .golangci.yaml | 22 +++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 .golangci.bck.yaml diff --git a/.golangci.bck.yaml b/.golangci.bck.yaml new file mode 100644 index 0000000..5e8a3e5 --- /dev/null +++ b/.golangci.bck.yaml @@ -0,0 +1,6 @@ +run: + timeout: 3m + +linters: + enable: + - gofmt diff --git a/.golangci.yaml b/.golangci.yaml index 5e8a3e5..38445ab 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,6 +1,22 @@ -run: - timeout: 3m - +version: "2" linters: + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + paths: + - third_party$ + - builtin$ + - examples$ +formatters: enable: - gofmt + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ From e23e96edbbf46d2aa4ad79f7bd6dce271f7555e6 Mon Sep 17 00:00:00 2001 From: 012xx Date: Wed, 21 Jan 2026 09:43:43 +0000 Subject: [PATCH 5/7] fix: improve logic for displaying diff summary in jsonnet formatter --- hooks/jsonnet-fmt-hook/main.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hooks/jsonnet-fmt-hook/main.go b/hooks/jsonnet-fmt-hook/main.go index 6a2df41..0492b20 100644 --- a/hooks/jsonnet-fmt-hook/main.go +++ b/hooks/jsonnet-fmt-hook/main.go @@ -99,11 +99,12 @@ func summarizeDiff(diffs []diffmatchpatch.Diff) *FileDiff { endWithLineBreak = text[len(text)-1:] == "\n" writeLineCount := min(maxShowLine, len(lines)) - if i == 0 { + switch i { + case 0: showTail = true - } else if i == lastDiffIdx { + case lastDiffIdx: showHead = true - } else { + default: showTail = true showHead = true } From 68332035875fa194eb95aafc89156585502287a0 Mon Sep 17 00:00:00 2001 From: 012xx Date: Wed, 21 Jan 2026 09:51:14 +0000 Subject: [PATCH 6/7] fix: change golangci-lint installation method to use curl script --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e63a2d2..1f74f8e 100644 --- a/Makefile +++ b/Makefile @@ -34,4 +34,4 @@ setup: @go install github.com/google/go-jsonnet/cmd/jsonnet-lint@$(JSONNET_VERSION) @go install github.com/google/go-jsonnet/cmd/jsonnetfmt@$(JSONNET_VERSION) - @go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_VERSION) + @curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin $(GOLANGCI_VERSION) From 6dcc74926240232da25cd1c7fbfaf798a4c5f1a1 Mon Sep 17 00:00:00 2001 From: 012xx Date: Thu, 22 Jan 2026 05:21:36 +0000 Subject: [PATCH 7/7] delete: remove unused golangci-lint backup configuration file --- .golangci.bck.yaml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 .golangci.bck.yaml diff --git a/.golangci.bck.yaml b/.golangci.bck.yaml deleted file mode 100644 index 5e8a3e5..0000000 --- a/.golangci.bck.yaml +++ /dev/null @@ -1,6 +0,0 @@ -run: - timeout: 3m - -linters: - enable: - - gofmt