diff --git a/scripts/githooks/commit-msg b/scripts/githooks/commit-msg index e91555c..dfc03fc 100644 --- a/scripts/githooks/commit-msg +++ b/scripts/githooks/commit-msg @@ -51,6 +51,16 @@ test "" = "$(grep '^Signed-off-by: ' "$1" | # TODO: go-gitlint dir set GITLINT_DIR="./_output/tools/go-gitlint" +if ! command -v $GITLINT_DIR &>/dev/null; then + printMessage "$GITLINT_DIR not found. Attempting to install it..." + make tools || make tools.verify.go-gitlint + if [ $? -ne 0 ] + then + printError "Failed to install $GITLINT_DIR. Please manually run 'make tools' OR 'make tools.verify.go-gitlint' to install it." + exit 1 + fi +fi + $GITLINT_DIR \ --msg-file=$1 \ --subject-regex="^(build|chore|ci|docs|feat|feature|fix|perf|refactor|revert|style|test)(.*)?:\s?.*" \ @@ -61,9 +71,6 @@ $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." - fi printError "Please fix your commit message to match kubecub coding standards" printError "https://gist.github.com/cubxxw/126b72104ac0b0ca484c9db09c3e5694#file-githook-md" exit 1