diff --git a/scripts/githooks/commit-msg b/scripts/githooks/commit-msg index e91555c..a1420d8 100644 --- a/scripts/githooks/commit-msg +++ b/scripts/githooks/commit-msg @@ -51,6 +51,12 @@ test "" = "$(grep '^Signed-off-by: ' "$1" | # TODO: go-gitlint dir set GITLINT_DIR="./_output/tools/go-gitlint" +if [ ! -f "$GITLINT_DIR" ]; then + printError "go-gitlint not found, installing..." + # Try to install go-gitlint. Attempt both known commands. + make tools || make tools.verify.go-gitlint +fi + $GITLINT_DIR \ --msg-file=$1 \ --subject-regex="^(build|chore|ci|docs|feat|feature|fix|perf|refactor|revert|style|test)(.*)?:\s?.*" \ @@ -62,7 +68,7 @@ $GITLINT_DIR \ if [ $? -ne 0 ] then if ! command -v $GITLINT_DIR &>/dev/null; then - printError "$GITLINT_DIR not found. Please run 'make tools' OR 'make tools.verify.go-gitlint' make verto install it." + printError "$GITLINT_DIR not found and has been installed. Please run 'make tools' OR 'make tools.verify.go-gitlint' if the issue persists." fi printError "Please fix your commit message to match kubecub coding standards" printError "https://gist.github.com/cubxxw/126b72104ac0b0ca484c9db09c3e5694#file-githook-md" diff --git a/scripts/githooks/pre-commit b/scripts/githooks/pre-commit index 7660e5d..e5575eb 100644 --- a/scripts/githooks/pre-commit +++ b/scripts/githooks/pre-commit @@ -41,6 +41,16 @@ printMessage "Running local kubecub pre-commit hook." # flutter format . # https://gist.github.com/cubxxw/126b72104ac0b0ca484c9db09c3e5694#file-githook-md +# Check if go-gitlint is available and install if necessary +if [ ! -f "${GITLINT_DIR}" ]; then + printError "${GITLINT_DIR} not found, installing..." + make tools || make tools.verify.go-gitlint +fi +if [ ! -f "$GITLINT_DIR" ]; then + printError "go-gitlint not found and has been installed. Please run 'make tools' OR 'make tools.verify.go-gitlint' if the issue persists." + make tools || make tools.verify.go-gitlint +fi + # TODO! GIT_FILE_SIZE_LIMIT=50000000 git commit -m "test: this commit is allowed file sizes up to 50MB" # Maximum file size limit in bytes limit=${GIT_FILE_SIZE_LIMIT:-2000000} # Default 2MB