Skip to content

Adding pre-commit hooks - #26

Merged
javuto merged 1 commit into
developfrom
pre-commit-hooks
Oct 16, 2026
Merged

javuto merged 1 commit into
developfrom
pre-commit-hooks

Conversation

@javuto

@javuto javuto commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

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.

@javuto javuto added the 🛠️ development Development related issues label Oct 16, 2026
@javuto
javuto merged commit 619e2b8 into develop Oct 16, 2026
2 checks passed
@javuto
javuto deleted the pre-commit-hooks branch October 16, 2026 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🛠️ development Development related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant