diff --git a/.githooks/pre-commit b/.githooks/pre-commit deleted file mode 100755 index 57e1fe952c..0000000000 --- a/.githooks/pre-commit +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -staged_go_files=$(git diff --cached --name-only | grep ".go$") -[ -z "$staged_go_files" ] && exit 0 - -# Ensure code is formatted correctly -unformatted_files=$(gofmt -l "$staged_go_files") -if [ -n "$unformatted_files" ]; then - echo >&2 "Formatting issues found. Please run 'make code/fix' to fix them." - exit 1 -fi - -# Ensure packages which the staged .go files belongs to passes standard checks -staged_go_files=$(git diff --cached --name-only | grep ".go$" | awk -F/ '{print $1}' | uniq) -[ -z "$staged_go_files" ] && exit 0 - -go_vet_results="" -for file in $staged_go_files -do - go_vet_results+=$(go vet ./"${file}"/... 2>&1 >/dev/null) -done - -go_vet_results=${go_vet_results//# command-line-arguments/} - -if [ -n "$go_vet_results" ]; then - echo >&2 "Standard checks failed. Please fix the following issues before continuing: ${go_vet_results}" - exit 1 -fi - -exit 0 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5d20873098..824a772b78 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ repos: - id: detect-secrets args: ["--baseline", ".secrets.baseline"] - repo: https://github.com/golangci/golangci-lint - rev: v1.52.2 + rev: v1.53.2 hooks: - id: golangci-lint - repo: https://github.com/pre-commit/pre-commit-hooks @@ -27,7 +27,7 @@ repos: exclude: '^(?:secrets/db.*|internal/dinosaur/pkg/api/(admin|private|public)/.*|pkg/client/redhatsso/api/.*)$' # Matches either secrets/db.* files or the generated files under internal/dinosaur/pkg/api/(admin|private|public) and pkg/client/redhatsso/client/api. - id: check-json - repo: https://github.com/shellcheck-py/shellcheck-py - rev: v0.9.0.2 + rev: v0.9.0.5 hooks: - id: shellcheck # Ignore scripts generated by openapi-generator. diff --git a/Makefile b/Makefile index 7afb57149e..a9524b2965 100644 --- a/Makefile +++ b/Makefile @@ -241,7 +241,7 @@ help: all: openapi/generate binary .PHONY: all -# Set git hook path to .githooks/ +# Install pre-commit hooks .PHONY: setup/git/hooks setup/git/hooks: -git config --unset-all core.hooksPath