<#26 Adding pre-commit hooks> Pull request opened ...
# osctrl
g
#26 Adding pre-commit hooks Pull request opened by javuto Add pre-commit hooks Adds a
.pre-commit-config.yaml
, so the checks CI runs, plus some it doesn't, run before every commit. It follows osctrl's setup and uses the same hook repos and versions. Install once per clone with
pre-commit install
. Hooks • File checks (
pre-commit-hooks
v6.0.0): • JSON and YAML syntax, and the launchd plist parsed as XML. pre-commit doesn't treat
.plist
as XML, so
check-xml
targets it explicitly. • Merge-conflict markers, broken symlinks, private keys and AWS credentials. • End-of-file and trailing-whitespace fixes. • Files over 800 KB, to catch stray build output such as a cross-compiled
osctrld.exe
. • golangci-lint v2.14.0, the same version CI pins. It uses the
golangci-lint-full
hook, which lints the whole module like CI does. The default hook only lints changed files, which breaks the
unused
linter. •
gofmt
.
CI doesn't check formatting. • golangci-lint for
GOOS=windows
.
A native lint run skips every
//go:build windows
file. This hook uses the golangci-lint on
PATH
. •
go test -race
.
osctrl's Python-only checks are left out, and so is
go-static-check
, since golangci-lint already runs staticcheck. The README's Development section explains how to install and run the hooks. Validation • Ran
pre-commit run --all-files
against a clean checkout of
HEAD
. Every hook passed except
end-of-file-fixer
, which found that
Makefile
has no trailing newline. That is fixed automatically the first time a commit touches
Makefile
. • Confirmed
check-xml
actually validates the plist: a deliberately broken copy fails to parse. • `pre-commit validate-config`: valid. jmpsec/osctrld