Files
restic-manager/.pre-commit-config.yaml
T
steve 2d40002355
CI / Test (linux/amd64) (pull_request) Successful in 29s
CI / Lint (pull_request) Failing after 16s
CI / Build (windows/amd64) (pull_request) Successful in 21s
CI / Build (linux/amd64) (pull_request) Successful in 21s
CI / Build (linux/arm64) (pull_request) Successful in 21s
ci: enforce lint locally via pre-commit hook
The repo had a .pre-commit-config.yaml entry for golangci-lint
already, but pinned to v1.61.0 — which doesn't grok the v2 schema
we just migrated to, so it would crash if anyone ever ran it. Hence
nobody did.

Replace the third-party hook blocks with local hooks that call
whatever tool is on the developer's PATH (gofumpt + go vet +
golangci-lint). That way the version of each tool tracks what the
developer would invoke by hand — no drift between hook config and
binary.

Add 'make setup' as a one-liner per-clone bootstrap:
  * installs gofumpt + golangci-lint via go install if missing
  * installs the pre-commit hooks via 'pre-commit install'

end-of-file-fixer auto-fixed two existing files (web/static/css/
styles.css and ask.md) — trailing newlines, harmless.
2026-05-03 21:26:24 +01:00

49 lines
1.5 KiB
YAML

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
args: ["--maxkb=512"]
- id: check-merge-conflict
- id: mixed-line-ending
args: ["--fix=lf"]
# Go-specific hooks. Local hooks (rather than third-party repos) so
# the version of each tool tracks whatever is on the developer's
# PATH, matching what they'd use to run the same checks by hand.
# Required tools:
# * go (toolchain matching go.mod)
# * gofumpt — `go install mvdan.cc/gofumpt@latest`
# * golangci-lint — `go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.6`
#
# Install + activate the hooks once per clone:
# pre-commit install
- repo: local
hooks:
- id: gofumpt
name: gofumpt
description: Format Go files with gofumpt (stricter superset of gofmt)
entry: gofumpt -l -w
language: system
types: [go]
pass_filenames: true
- id: go-vet
name: go vet
description: Run go vet across all packages
entry: go vet ./...
language: system
types: [go]
pass_filenames: false
- id: golangci-lint
name: golangci-lint
description: Run golangci-lint against the whole module (matches CI)
entry: golangci-lint run ./...
language: system
types: [go]
pass_filenames: false