Skip to content

Commit 45a5179

Browse files
julianknutsenclaude
andcommitted
chore: add pre-commit hook (fmt + lint gate)
Activate with: git config core.hooksPath .githooks Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 064b16e commit 45a5179

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

.githooks/pre-commit

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
staged_go_files=$(git diff --cached --name-only --diff-filter=ACM -- '*.go')
5+
[ -z "$staged_go_files" ] && exit 0
6+
7+
golangci-lint fmt ./... 2>/dev/null
8+
echo "$staged_go_files" | xargs git add
9+
10+
golangci-lint run --new-from-rev=HEAD --fix || exit 1
11+
echo "$staged_go_files" | xargs git add

0 commit comments

Comments
 (0)