This repository uses pre-commit to automatically
check and format code before every commit. The configuration lives in
.pre-commit-config.yaml.
# Install pre-commit (one-time, system-wide)
pip install pre-commit
# or via a package manager, e.g.
pacman -S pre-commit
# Install the hooks into the local .git/hooks/ directory
pre-commit installFrom now on the hooks run automatically on every git commit.
# Run all hooks against all files
pre-commit run --all-files
# Run a specific hook
pre-commit run golangci-lint --all-files
# Bump hook versions to the latest releases
pre-commit autoupdateGeneral hygiene — pre-commit/pre-commit-hooks
| Hook | Purpose |
|---|---|
trailing-whitespace |
Trims whitespace at the end of lines |
end-of-file-fixer |
Ensures files end with exactly one newline |
mixed-line-ending |
Normalises line endings |
detect-private-key |
Prevents accidental commits of private keys (internal/shared/redact_test.go is excluded because it contains test fixtures) |
check-merge-conflict |
Blocks commits with unresolved merge markers |
Character normalisation — Lucas-C/pre-commit-hooks
| Hook | Purpose |
|---|---|
remove-crlf |
Replaces CRLF with LF |
remove-tabsis currently disabled in the config.
Smart-quote fix — sirosen/fix-smartquotes
| Hook | Purpose |
|---|---|
fix-smartquotes |
Replaces typographic quotes with ASCII " / ' |
Go linting — golangci/golangci-lint
| Hook | Purpose |
|---|---|
golangci-lint |
Lints only the currently changed Go files (--new-from-rev HEAD --fix) — fast enough for pre-commit |
golangci-lint-config-verify |
Validates the syntax of .golangci.yml |
The linter selection (errcheck, govet, staticcheck, unused,
ineffassign) and exclusions are defined in .golangci.yml. The CI workflow
additionally runs the full variant across all files via
golangci/golangci-lint-action.
Hook versions are maintained by Renovate — the
pre-commit manager is explicitly enabled. Minor and patch updates are merged
automatically, major updates require manual approval.
Alternatively, run pre-commit autoupdate locally to bump
.pre-commit-config.yaml to the latest tags.
- A hook fails even though the code looks correct: run
pre-commit cleanto clear the hook cache, thenpre-commit run --all-filesagain. - golangci-lint reports different findings locally vs. in CI: the
pre-commit hook uses
--new-from-rev HEAD, i.e. only newly introduced findings block the commit. CI lints the entire codebase. - Bypass a hook (only in exceptional cases):
git commit --no-verify. CI will still catch skipped findings.