mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-29 17:52:32 +00:00
Only run fmtcheck on changed files pre-commit (#21747)
The pre-commit hook was taking quite a while to run. Let's just check changed files to avoid unnecessary `go fmt` on the entire tree.
This commit is contained in:
@@ -62,11 +62,14 @@ ui_lint() {
|
||||
|
||||
backend_lint() {
|
||||
# Silently succeed if no changes staged for Go code files.
|
||||
if git diff --name-only --cached --exit-code -- '*.go'; then
|
||||
staged=$(git diff --name-only --cached --exit-code -- '*.go')
|
||||
ret=$?
|
||||
if [ $ret -eq 0 ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
./scripts/gofmtcheck.sh || block "Backend linting failed; run 'make fmt' to fix."
|
||||
# Only run fmtcheck on staged files
|
||||
./scripts/gofmtcheck.sh "${staged}" || block "Backend linting failed; run 'make fmt' to fix."
|
||||
}
|
||||
|
||||
for CHECK in $CHECKS; do
|
||||
|
||||
Reference in New Issue
Block a user